How to cancel UITextView using the Finish button

I was wondering if any of you knew how to access this button that appears above the keyboard when editing.

I have seen this before, there is a transparent black area above the keyboard, and there is a blue Finish button on the right.

I could do it manually using my own animations and buttons above the keyboard in my application to resign UITextView, but I would prefer to use the Apple GUI elements that people know.

Does anyone have any info on where this Done button comes from?

+4
source share
1 answer

You really don't get access to this button, but through the UITextViewDelegate protocol, you can essentially:

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITextViewDelegate_Protocol/Reference/UITextViewDelegate.html

Implement

- (void)textViewDidEndEditing:(UITextView *)textView 

and assign the UIViewController containing the text view to the textview delegate.

Inside this procedure, you can do what you want! You will need to call

 resignFirstResponder 

method.

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIResponder_Class/Reference/Reference.html#//apple_ref/occ/instm/UIResponder/resignFirstResponder

You will need to implement a keyboard style that implements this blue button.

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITextInputTraits_Protocol/Reference/UITextInputTraits.html#//apple_ref/occ/intf/UITextInputTraits

FINAL ANSWER

 - (void)textViewDidEndEditing:(UITextView *)textView{ [textView resignFirstResponder]; } 
+3
source

All Articles