iOS Xcode keyboard done button function
ios, keyboard, objective-c, xcode
Solution
Make the controller a delegate of the UITextField/UITextView in IB or from code like `textField.delegate = self;`
Editted: For this you need to declare the controller a delegate of UITextFieldDelegate/UITextViewDelegate as
@interface Controller : <UITextFieldDelegate> { ...
, then override the method:
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
for UITextField and
-(BOOL)textViewShouldEndEditing:(UITextView *)textView{
[textView resignFirstResponder];
return YES;
}
for UITextView
Problem
I just can't make the "Done" button to quit the keyboard. I used this in my controller.h file ``` - (IBAction)textFieldDoneEditing:(id)sender; ``` and this for my controller.m file ``` - (IBAction)textFieldDoneEditing:(id)sender { [sender resignFirstResponer]; } ``` and I'm mixed up in wiring the .xib part.