iOS中收回键盘
2016-04-28 00:00
316 查看
让虚拟键盘在输入完后收回(点击屏幕空白处就收回了)
#import "ViewController.h" @interface ViewController (){ UITextField *myTextField; } @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; //新建一个UITextField myTextField = [[UITextField alloc]initWithFrame:CGRectMake(0, 100, 300, 50)]; //设置边框 [myTextField setBorderStyle:UITextBorderStyleRoundedRect]; //设置键盘的样式 myTextField.keyboardType = UIKeyboardTypeNamePhonePad; [self.view addSubview:myTextField]; } //让虚拟键盘在完成输入后收回(点空白处就收回了) -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ [myTextField resignFirstResponder]; }
相关文章推荐
- iOS中判断程序是不是第一次运行(新手引导界面用)
- iOS中各种手机型号的分辨率及软件图标的制作
- iOS中单例NSUserDefaults的使用 (转)
- iOS获取设备型号、设备类型等信息
- ios 播放声音文件
- iOS CocoaPods安装和使用图解
- ios极光推送使用总结
- ios 摇一摇
- iOS开发之传感器
- iOS Block
- ios 十六进制与十进制转换
- iOS获取当前时间及前一天或后一天时间
- iOS 中KVC、KVO、NSNotification、delegate 总结及区别
- iOS 页面传值总结
- iOS hidesBackButton正确姿势 ios键盘联想屏蔽
- Ios userDefaultes本地存储
- 字典中添加不同类型的值(ios)
- iOS 蓝牙开发流程
- iOS开发多线程篇—创建线程
- iOS 实现缓存清理