2

iPad:

I have a tableView full of an arbitrary number of text fields and buttons in different rows.

When you press a button I a modal popup will popup. If you press a button while editing a text field (and the keyboard is displayed on the iPad) something hilarious will happen. The popover will be 75% off the corner of the screen (with a quarter visible in quarter.)

To avoid this bad behavior, how do you resignFirstResponder on all textfields in the table when the button is pressed?

MikeN
  • 45,039
  • 49
  • 151
  • 227

1 Answers1

1

You can implement this method:

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

As long as the textfields' delegate are your current view controller, it should work fine :)

Koh Jing Yu
  • 123
  • 1
  • 6
  • This doesn't work. This only triggers when you hit done/enter/return in a field. Clicking on a button when in the text field doesn't do anything. – MikeN Apr 13 '11 at 04:53