我正在使用自定义UIAlertView。当弹出错误时,我按照自己的意愿调用了FirstResponder。当用户点击下面看到的kButtonTitle指定的完成按钮时,会出现问题。一旦用户单击识别错误的按钮,我试图让键盘弹出。我试过了:
if (alert)
[textField resignFirstResponder];
else
[_nameTextField becomeFirstResponder];
}
以上似乎没有任何改变。我将整个textFieldShouldReturn方法的代码粘贴在下面:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
NSString *name = _nameTextField.text;
if ((name.length > 6) && [name containsString:@" "])
{
[textField resignFirstResponder];
} else {
SCLAlertView *alert = [[SCLAlertView alloc] init];
alert.backgroundType = Blur;
NSString *kNoticeTitle = @"Error";
[alert showNotice:self title:kNoticeTitle subTitle:@"Please input both your first and last name" closeButtonTitle:kButtonTitle duration:0.0f];
if (alert)
[textField resignFirstResponder];
else
[_nameTextField becomeFirstResponder];
}
return YES;
}
非常感谢任何帮助或评论!提前谢谢!
答案 0 :(得分:0)
也许你可以使用带有自定义操作的按钮而不是默认的关闭按钮。
[textField resignFirstResponder];
SCLAlertView *alert = [[SCLAlertView alloc] init];
[alert addButton:kButtonTitle actionBlock:^{
[_nameTextField becomeFirstResponder];
}];
[alert showNotice:self title:kNoticeTitle
subTitle:@"Please input both your first and last name"
closeButtonTitle:nil duration:0.0f];