francis
francis

Reputation: 710

UITextViews hide keyboard button won't work

All UITextViews on my application just won't hide the keyboard when i click the "Hide Keyboard" button on the input keyboard.

This is very strange since UITextFields behave normally and theres absolutely no delegation class linked to the TextViews, so there is absolutely no reason for this behavior.

Anyone who faced this problem and solved it?

Upvotes: 0

Views: 350

Answers (1)

LJ Wilson
LJ Wilson

Reputation: 14427

Set the return key to something like "Done" and then use the delegate method and see if a line break occurred:

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

Upvotes: 1

Related Questions