Domanda

I've looked in many places and it seems everyone uses IB. I like it, but find it more fun writing it all out. This being said, I'm having difficulty dropping my keyboard after editing is done. Here's an example.

-(void)textStuff
{

    UITextField *someField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];//not true size
}

Here I've tried the resign firstresponder and even a BOOL to say are you editing, YES, then make that keyboard first responder dangit....oh, you're done editing...good, now resign that first responder.....none has worked as of yet. Any help would be greatly appreciated.

Thanks

È stato utile?

Soluzione

1).

[self.view endEditing:YES];

2).
you set the delegate method.

 SOMEFIELD.text =delegate;

And .h file

@interface yourViewController  : UIViewController<UITextFieldDelegate>

and in .m file you add the delegate method of the textfield

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
        [textField resignFirstResponder];
        return YES;
    }

Altri suggerimenti

all you have to do is set someField's delegate your view controller and implement following method,

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return YES;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top