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.
If you want that text control to stop waiting for input – which in turn dismisses the keyboard – you should call its resignFirstResponder() method, which passes the first responder baton to the next waiting component.
You need to add a ScrollView and set a bottom padding of the size of the keyboard so the content will be able to scroll when the keyboard appears. All you have to do now is to embed your content inside the custom ScrollView .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With