我有這個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