我有这个UIAlertview,我试图用它来调用一个函数。显示了fogotpassword alert视图,然后重置alertview出现,但是当我试图调用NSLog(@“Password”)时,通过按下第一个按钮重置alertview它不会被调用。相反,重置的alertview按钮会再次弹出。我将不胜感激任何帮助。UIAlertview没有调用正确的功能
-(void)viewDidLoad{
forgotPassword = [[UIAlertView alloc] initWithTitle:@"Login Error"
message:@"Your login credentials do not match"
delegate:self
cancelButtonTitle:@"Try Again"
otherButtonTitles: @"Forgot Password",nil];
[forgotPassword show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
forgotPassword.tag = 1;
resetPassword.tag = 2;
if (buttonIndex == 1 && forgotPassword.tag ==1)
{
resetPassword = [[UIAlertView alloc] initWithTitle: @"Forgot Password"
message:@"Email" delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Reset Password", nil];
[resetPassword setAlertViewStyle:UIAlertViewStylePlainTextInput];
[resetPassword show];
NSLog(@"RESET");
}
if (buttonIndex == 1 && resetPassword.tag == 2) {
NSLog(@"Password");
}
}
谢谢,只要时限到了,你会得到一个复选标记。我只是按照另一个stackoverflow的答案,我想这不是最好的方法 – user2997441
请记住,使用标签而不是ivars的警报视图也非常好。您只需在创建警报视图时设置标记,而不是在委托方法中。 – rmaddy