How to hide the keyboard programmatically in iphone

后端 未结 6 2008
春和景丽
春和景丽 2021-01-11 13:43

How to hide the keyboard programmatically in iphone?

6条回答
  •  孤城傲影
    2021-01-11 14:01

    If you are using textview then

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

    and if you are using textfield then

    -(BOOL)textFieldShouldReturn:(UITextField*)textField;
     {
    
    [textField resignFirstResponder];
    
     }
    

提交回复
热议问题