Instead of calling resignFirstResponder you should call endEditing: in the view itself or in any of its superviews. endEditing: will search for all subqueries for any view that has the status of the first responder and ask him to resign.
endEditing: accepts a boolean flag as a parameter. If set, this will force the first responder to resign; otherwise, you can let it maintain focus (if the input is invalid, for example). For UITextField, this is determined by the delegate method shouldEndEditing:
In general, a good template to use:
- (void)saveAction:(id)sender { if ([self.view endEditing:NO]) { NSString *text = self.textField.text;
benzado
source share