1-1Did 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];
}
}
1-2 点击屏幕得时候隐藏键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent
*)event{
UITouch *touch=[[event allTouches] anyObject];
if (touch.tapCount >=1) {
[chi resignFirstResponder];
[meter resignFirstResponder];
[feet resignFirstResponder];
}
}
1-2的方法相当于屏幕任何位置的点击事件(除了各组件的点击处)可以在这个方法里执行要隐藏或remove的view。