我有一些 UITextViews 的视图。用户可以输入人员数据、姓名、姓氏、电子邮件等。编辑完成后,用户点击右上角的“完成”,视图导航回之前的视图,如下所示:
- (void)save:(id)sender
{
[self.view.window endEditing:YES];
if (self.data ...)
{
[self updateUser];
[self.navigationController popViewControllerAnimated:YES];
}
}
客户要求在某些字段中添加一些验证,例如电子邮件。验证后,UIAlertView 会通知数据输入无效,因此不会存储数据。我的问题是AlertView的OK按钮调用了“save”方法,navigationController被调用,popViewControllertAnimated被调用。
这里的问题是,我想在 UIAlertView 之后避免自动导航到上一个视图(通过 popViewControllerAnimated),更准确地说,我想留在我的编辑视图上并输入一个新的有效电子邮件。
警报视图的代码是
- (void)alertInvalid {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"" message:NSLocalizedString(@"res_CurrentPasswordErrorAlert",nil)
delegate:nil cancelButtonTitle: NSLocalizedString(@"res_OK",nil) otherButtonTitles:nil];
[alertView show];
}
这是通过-(BOOL)textFieldShouldEndEditing:(UITextField *)textField
方法调用的。那么,如何在当前 UITextView 再次响应的警报消息之后修改我的代码?