iOS 按下return键让键盘消失
2016-09-01 16:37
357 查看
对于UITextField来说:
1.设置textfiled的代理
2.实现代理方法 textFieldShouldReturn
对于UITextView来说,UITextView同理:
1.设置textView代理
2.实现代理方法
- (BOOL)textView:(UITextView )textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString )text
1.设置textfiled的代理
2.实现代理方法 textFieldShouldReturn
- (BOOL)textFieldShouldReturn:(UITextField *)textField{ /* 辞去第一响应者 */ [textField resignFirstResponder]; return YES; }
对于UITextView来说,UITextView同理:
1.设置textView代理
2.实现代理方法
- (BOOL)textView:(UITextView )textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString )text
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ if ([text isEqualToString:@"\n"]) { [textView resignFirstResponder]; return NO; } return YES; }
相关文章推荐
- iOS 点击return或者点击屏幕键盘消失
- ios return 键盘消失
- iOS 点击return或者点击屏幕键盘消失
- iOS菜鸟学习——UITextView return键隐藏键盘
- iOS 上常用的两个功能:点击屏幕和return退出隐藏键盘和解决虚拟键盘挡住UITextField的方法
- ios之UITextField使用技巧概述/代理过滤字符/按return隐藏键盘/通知等用法
- iOS中UITextField return键隐藏键盘
- iOS让键盘消失的技巧
- iOS 上常用的两个功能:点击屏幕和return退出隐藏键盘和解决虚拟键盘挡住UITextField的方法
- iOS 点击屏幕任意空白处,键盘消失
- IOS点击return隐藏键盘
- iOS: 让键盘消失的的4种方法
- textFieldShouldReturn 键盘无法消失 无法return的问题
- 技巧-iOS让键盘消失的方法
- ios王云鹤--iPhone中,点击换行,键盘消失。
- iOS开发-点击屏幕,键盘消失的极佳方法。
- iOS 上常用的两个功能:点击屏幕和return退出隐藏键盘和解决虚拟键盘挡住UITextField的方法
- ios王云鹤--iPhone中,点击换行,键盘消失。
- iOS: 让键盘消失的的4种方法
- iOS 上常用的两个功能:点击屏幕和return退出隐藏键盘和解决虚拟键盘挡住UITextField的方法