- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
NSInteger tag = textField.tag;
if(tag ==10 || tag ==11 || tag ==12){
if(keyboardVisible){//判断键盘是否显示
[textField resignFirstResponder];
}
[self moveTo:pickView andX:0 andY:HIGHT-230 andTime:0.3];
return NO;
}else{
return YES;
}
}
当键盘显示时,用[textField resignFirstResponder]
为什么不能隐藏键盘?
执行了这句代码,但是键盘不能隐藏......
if(keyboardVisible){//判断键盘是否显示
[textField resignFirstResponder];
}
我没看懂你问的问题,点击textfield是编辑状态。隐藏键盘?
没有创建时的代码 ,下面是推断
代理加了没
如果需要控制uitextfield,你需要加入代理声明
@interface uiviewcontroller <UITextFieldDelegate>//注意UITextFieldDelegate
声明textfiled
UITextField *textfiled = [UITextField new];
textfiled.delegate = self;//这一句要加入代理
如果你没有进行上述操作,请尝试以下,看是否可以了
试试[textField endEditing:YES];
已解决: [self.view endEditing:YES];