退出键盘的方式
2014-12-05 18:32
239 查看
方式1:一般键盘都是通过控件调用出来的,通过resign控件的第一响应者的身份可以成功退出键盘。- (IBAction)cal {
int result = [self.num1.text intValue] + [self.num2.text intValue];
self.result.text = [NSString stringWithFormat:@"%d",result];
<span style="color:#ff0000;"> [self.num1 resignFirstResponder];
[self.num2 resignFirstResponder];</span>
}
方式2:使整个控制器的View结束编辑。
<span style="font-size:24px;">- (IBAction)cal {
int result = [self.num1.text intValue] + [self.num2.text intValue];
self.result.text = [NSString stringWithFormat:@"%d",result];
<span style="color:#ff0000;">[self.view endEditing:YES];</span>
}</span>
int result = [self.num1.text intValue] + [self.num2.text intValue];
self.result.text = [NSString stringWithFormat:@"%d",result];
<span style="color:#ff0000;"> [self.num1 resignFirstResponder];
[self.num2 resignFirstResponder];</span>
}
方式2:使整个控制器的View结束编辑。
<span style="font-size:24px;">- (IBAction)cal {
int result = [self.num1.text intValue] + [self.num2.text intValue];
self.result.text = [NSString stringWithFormat:@"%d",result];
<span style="color:#ff0000;">[self.view endEditing:YES];</span>
}</span>
相关文章推荐
- UITextView 退出键盘的方式
- Cocos2dx 3.2键盘监听的打开方式以及点击两次返回退出的实现方法
- UITextView 退出键盘的方式
- UITextView 退出键盘的方式
- IOS 关闭键盘 退出键盘 的5种方式
- UITextView和UITextField退出键盘的方式
- UITextView 退出键盘的方式
- iOS 关闭键盘 退出键盘 的5种方式
- UITextView UITextField退出键盘的常用三种方式
- 总结IOS关闭键盘/退出键盘的五种方式
- UITextView 退出键盘的方式
- iOS 【UIKit-UITextField 退出键盘的几种方式/监听方式】
- 使用InputMethodManager 退出键盘最灵活的方式
- IOS 关闭键盘 退出键盘 的5种方式
- UITextView 退出键盘的方式
- IOS 关闭键盘 退出键盘 的5种方式
- ios 里退出键盘的几种方式
- Cocos2dx 3.2键盘监听的打开方式以及点击两次返回退出的实现方法
- iOS关闭键盘退出键盘的几种方式
- IOS 关闭键盘 退出键盘 的5种方式(转)