The proper way to handle this is to add the done button in the inputAccessoryView to the UITextView . inputAccessoryView is a panel that sometimes appears above the keyboard.
To implement inputAccessoryView , simply add this method (or its variant) and call it in viewDidLoad .
- (void)addInputAccessoryViewForTextView:(UITextView *)textView{ //Create the toolbar for the inputAccessoryView UIToolbar* toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)]; [toolbar sizeToFit]; toolbar.barStyle = UIBarStyleBlackTranslucent; //Add the done button and set its target:action: to call the method returnTextView: toolbar.items = [NSArray arrayWithObjects:[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil], [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(returnTextView:)], nil]; //Set the inputAccessoryView [textView setInputAccessoryView:toolbar]; }
Then cancel the button click by executing the action method called with resignFirstResponder .
- (void) returnBreakdown:(UIButton *)sender{ [self.textView resignFirstResponder]; }
This will cause the βFinishβ button to appear on the standard toolbar above the keyboard.
source share