How do I dismiss a UITextView using the Done keyboard button? [duplicate] How do I dismiss a UITextView using the Done keyboard button? [duplicate] objective-c objective-c

How do I dismiss a UITextView using the Done keyboard button? [duplicate]


There’s no shouldReturn on UITextView, but you can implement UITextViewDelegate and watch for insertions:

- (BOOL) textView: (UITextView*) textView    shouldChangeTextInRange: (NSRange) range    replacementText: (NSString*) text{    if ([text isEqualToString:@"\n"]) {        [textView resignFirstResponder];        return NO;    }    return YES;}

Edit: And yes, sorry, this is a dupe.