zoukankan      html  css  js  c++  java
  • iOS 隐藏键盘的几种常见方法

    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]。

  • 相关阅读:
    html_Dom
    html_javascript
    html_之css
    协程
    进程和线程的总结
    html_基础标签
    html_头部<meta>设置
    Python_queue单项队列
    Python_paramiko模块
    Python_多进程multiprocessing
  • 原文地址:https://www.cnblogs.com/ficow/p/5223314.html
Copyright © 2011-2022 走看看