1.设置return key,然后为Did End On Exit事件添加响应方法,并在方法内添加代码:[self.textfieldName resignFirstResponder]。

2.将背景view设置为UIControl类,然后为Touch Down事件添加响应方法,并在方法内添加代码:[self.textfieldName resignFirstResponder]。

3.重载- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event方法,并在方法内添加代码:[self.textfieldName resignFirstResponder] 或者 [self.view endEditing:YES]

4.直接执行[[UIApplication sharedApplication]sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil]; 用于在获得当前UIViewController比较困难的时候。

5.直接执行[[[UIApplication sharedApplication]keyWindow]endEditing:YES]。

相关文章:

  • 2021-09-03
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
  • 2021-11-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2021-06-18
相关资源
相似解决方案