Question

i was wondering if any of you knew how to get access to that done button that appears above the keyboard when editing.

I have seen it before, above the keyboard there is a transparent black area and on the right there is a blue "Done" Button.

I could do this by hand with my own animations and buttons above the keyboard in my app to resign the UITextView, but i would prefer to use Apple GUI elements that people know.

So does anybody have any information about where this "Done" button comes from?

Was it helpful?

Solution

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

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

Implement the

- (void)textViewDidEndEditing:(UITextView *)textView

routine, and assign the UIViewController holding the textview to the textview' delegate.

Inside of that routine, you can do what you wish! You will need to call the

resignFirstResponder

method.

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

You will have to implement the style of keyboard that implements that blue done 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];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top