Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to dismiss keyboard in iOS simulator

I cannot get textFieldShouldEndEditing to call. I have re created the links in interface builder and tried, but nothing seems to work. Any idea why this would not be called?

Edit

 -(BOOL)textFieldShouldEndEditing:(UITextField *)textField
 {
     NSLog(@"Done editing...");
     [textField resignFirstResponder];
      return YES;
 }

1 Answers

Try this code .

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
 [Self.view EndEditing:YES];
 return YES;    
}

Also use _myTextField.delegate = self; in your ViewDidLoad

And in your .h file, add <UITextFieldDelegate> after the name of your class.

like image 118
Siba Prasad Hota Avatar answered Oct 21 '25 15:10

Siba Prasad Hota