Implement the shouldChangeTextInRange: delegate method Use below approach and the solution work only with @"\n" (new line character) (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { if (text isEqualToString:@"\n") { textView resignFirstResponder; // Return FALSE so that the final '\n' character doesn't get added return NO; } // For any other character return TRUE so that the text gets added to the view return YES; }.
Implement the shouldChangeTextInRange: delegate method. Use below approach and the solution work only with @"\n" (new line character). - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { if (text isEqualToString:@"\n") { textView resignFirstResponder; // Return FALSE so that the final '\n' character doesn't get added return NO; } // For any other character return TRUE so that the text gets added to the view return YES; }.
I have that set up. How can I detect when that is pressed. – Richard J.
Ross III Jun 20 at 13:35 set textfield delegate like myTextField. Delegate = self; and return YES in textFieldShouldReturn method; – Jhaliya Jun 20 at 13:39 @Jhaliya please Read the OP, it is a text VIEW not a text FIELD – Richard J. Ross III Jun 20 at 13:41 @Jhaliya I see you updated your post, Isn't it better to use 'YES' and 'NO' instead of 'TRUE' and 'FALSE' in obj-c?
– Richard J. Ross III Jun 20 at 13:48 @Richard J. Ross III : Updated answer.
– Jhaliya Jun 20 at 13:49.
You can use the delegate method - (void)textViewDidEndEditing:(UITextView *)textView { textView resignFirstResponder; } 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.
Did not work, Nothing different happened in my application. I have my delegate set up, and I have the keyboard setup the way I want it, but That code never gets called. – Richard J.
Ross III Jun 20 at 13:36 textViewDidEndEditing: is called when edition finished, in other words when the textView already resigned the first responder so textView resignFirstResponder; inside of it won't have any effect. – nacho4d Jun 20 at 13:37 You're right. I should read the documentation again – Pierre Jun 20 at 13:42.
Create Button type Done, then goto connectionInspector of textfield, and connect did End on Exit, to your IBAction(make the method you have written above an IBAction). Edit: In the case of TextView, you can use a trick: Make your background view a UIControll, and then on touch down event of that call your IBAction :).
How many times can I say that its a text VIEW not a text FIELD. – Richard J. Ross III Jun 20 at 13:40 1 the code you stuck, gives wrong intuition :P – rptwsthi Jun 20 at 13:46 well, I clearly stated that I saw that floating around the interwebs, and that it wouldn't work for a UITextView – Richard J.
Ross III Jun 20 at 13:47.
I have a UITextView that I need to resign first responder of when the user presses the 'Done' button on their keyboard. But that will not work for a UITextView. How can I tell when the user presses the done button on the keyboard?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.