iOS 开发小技巧

来源:互联网 发布:热血江湖传源码 编辑:程序博客网 时间:2024/05/16 15:58

一、收起键盘

在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

0 0
原创粉丝点击