转自:http://hi.baidu.com/jaywclove/blog/item/e79683315d82d3b45fdf0ed6.html
//触摸屏幕隐藏键盘
Did End On Exit 调用下面事件当点击键盘return得时候就会隐藏键盘
- (IBAction)textFieldShouldReturn:(UITextField *)textField {
//[sender resignFirstResponder];
if (textField == chi) {
[chi resignFirstResponder];
double m=[chi.textdoubleValue]/3.003;
double f=m *3.2808;
meter.text=[[NSStringalloc] initWithFormat:@"%.4f",m];
feet.text=[[NSStringalloc] initWithFormat:@"%.4f",f];
}
if (textField == meter) {
[meter resignFirstResponder];
}
if (textField == feet) {
[feet resignFirstResponder];
}
}
点击屏幕得时候隐藏键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch=[[event allTouches] anyObject];
if (touch.tapCount >=1) {
[chi resignFirstResponder];
[meter resignFirstResponder];
[feet resignFirstResponder];
}
}