/ Published in: iPhone
background tap - background should have type UIControl and method should be connected to the "touch down" action
textView - doesn't need to be connected to an action, but delegate needs to be connected to something that is a UITextViewDelegate
textField - delegate needs to be connected to something that is a UITextFieldDelegate and method should be connected to the "did end on exit" action
textView - doesn't need to be connected to an action, but delegate needs to be connected to something that is a UITextViewDelegate
textField - delegate needs to be connected to something that is a UITextFieldDelegate and method should be connected to the "did end on exit" action
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* * Gets rid of the keyboard when the user taps the background. */ - (IBAction) backgroundTap: (id) sender { [titleField resignFirstResponder]; [description resignFirstResponder]; } /* * Gets rid of the keyboard during edting when the "Return" key is pressed. * (works for a UITextView) */ - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range { if ([text isEqualToString:@"\n"]) { [textView resignFirstResponder]; return FALSE; } return TRUE; } /* * Gets rid of the keyboard during edting when the "Return" key is pressed. * (works for a UITextField) */ -(IBAction) textFieldDoneEditing:(id)sender { [sender resignFirstResponder]; }