Cancel the keyboard on the Finish button on the keyboard

I want to cancel the keyboard by pressing the "Finish" button on the keyboard. How can i do this? I have the following code =>

textView.returnKeyType = UIReturnKeyDone;

I have this code to limit the number of characters in textview =>

    - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range  replacementText:(NSString *)text
{

   if(range.length > text.length)
    {
        return YES;
    }

    else if([[textView text] length]  >= MAX_LENGTH_TEXTVIEW && range.length == 0)
    {
        [textView resignFirstResponder];
        return NO;

    }

    return YES;
} 

How can I refuse the keyboard when I click Finish on the keyboard? If I find "Finish", it does not resign, but proceeds to the next line (ie \ n). Is there any delegate method for the Done method or so? I do not get the method for "Finish" from the Apple documentation. Plz help me .... thanks in advance ....

+3
source share
2 answers

, :

if([[textView text] isEqualToString:@"\n"]) {
    [textView resignFirstResponder];
    return NO;
}
+3

Source: https://habr.com/ru/post/1791250/


All Articles