iOS 开发小技巧

作者: _浅墨_ | 来源:发表于2015-08-12 20:40 被阅读231次

一、收起键盘

在UIViewController中收起键盘,除了调用相应控件的resignFirstResponder方法外,还有另外三种方法:

  • 1.重载UIViewController中的touchesBegin方法,然后在里面执行[self.view endEditing:Yes];这样单击UIViewContrloller的任意地方,就可以收起键盘。
  • 2.直接执行[[UIApplication shareApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
  • 3.直接执行[[[UIApplication shareApplication] keyWindow] endEditing:YES];

二、直接上图了

1.JPG
2.JPG
3.JPG

相关文章

网友评论

  • FengxinLi:请问楼主的书是什么名字?<<实战技巧>>
    _浅墨_:@Fengxinliju 客气啊~
    FengxinLi:@沐风_ 好的 谢谢
    _浅墨_:@Fengxinliju 唐巧的《iOS开发进阶》,可以一看。

本文标题:iOS 开发小技巧

本文链接:https://www.haomeiwen.com/subject/fxiiqttx.html