I have been searching around the web for about an hour now, and cannot find any code to help me with this.
I have a UITextView
that I need to resign first responder of when the user presses the 'Done' button on their keyboard.
I have seen code floating around the internet like this:
-(BOOL) textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return NO;
}
But that will not work for a UITextView
.
Simply put,
How can I tell when the user presses the done button on the keyboard?
Implement the
shouldChangeTextInRange:
delegate method.Use below approach and the solution work only with @"\n" (new line character).
You can use the delegate method
You have to set your controller as the delegate for the TextView. For more methods you can have a look here: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITextViewDelegate_Protocol/Reference/UITextViewDelegate.html%23//apple_ref/doc/uid/TP40006897