我是 iOS 新手。
我正在处理警报视图。这是我的代码。这里有 2 个警报视图:successfulallert
和unsuccessfulallert
用于登录页面。我在这里也使用了 alertview 委托,它适用于两个 alertview,但我只想为成功的 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];
}
}