您的位置:首页 > 其它

退出键盘的方式

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: