how can I dismiss keyboard when I will just touch anywhere except UITextField?

后端 未结 10 2001
独厮守ぢ
独厮守ぢ 2021-02-19 11:12

Hello I have two UITextFields in my application, and want to dismiss the keyboard when I just touch anywhere except the UITextFields how can I do this?

10条回答
  •  北恋
    北恋 (楼主)
    2021-02-19 11:36

    The answer by Ishu is a good one. But I think you should also give a try to :

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    
      [self.view endEditing:YES];
    }
    

提交回复
热议问题