我是iOS新手。如何在點擊該警報視圖中的按鈕時關閉alertview
我正在使用alertviews。這是我的代碼。這裏有2個警報視圖:登錄頁面的successfulallert
和unsuccessfulallert
。我也在這裏使用了alertview委託,它將適用於兩個alertviews,但我只想爲成功的alertview工作,導航應該只爲成功的alertview完成。如果有人知道這一點,請幫助我。
NSString *responseOfResult = [[NSString alloc]initWithString:[result response]];
NSRange match;
// NSLog(@"string= %@", str);
match = [responseOfResult rangeOfString: @"successful"];
if(match.location == NSNotFound)
{
UIAlertView *unsuccessfulAllert = [[UIAlertView alloc]
initWithTitle:@"Alert"
message:responseOfResult
delegate:self
cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[unsuccessfulAllert show];
}
else {
UIAlertView *successfulAllert = [[UIAlertView alloc]
initWithTitle:@"Message" message:@"Login successful." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[successfulAllert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex == 0){
[[self navigationController]pushViewController:registerUserScreen animated:YES];
}
}
你在第二個if語句中缺少'.tag'。 – Mat
你是對的墊子。我現在糾正了錯誤。 –