我在這裏有一個小問題。我在UIAlertView中使用了一個if語句,並且我有兩種情況,都會導致UIAlertViews。但是,在一種情況下,我想僅解除UIAlertView,另一種情況是我想解除UIAlertView並查看以返回到根視圖。我應該如何正確格式化此代碼?
這個代碼描述是:
if([serverOutput isEqualToString:@"login.true"]){
[Alert dismissWithClickedButtonIndex:0 animated:YES];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
UIAlertView *success = [[UIAlertView alloc] initWithTitle:@"Success" message:@"The transaction was a success!"
delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[success show];
[success release];
} else {
UIAlertView *failure = [[UIAlertView alloc] initWithTitle:@"Failure" message:@"The transaction failed. Contact sales operator!"
delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[failure show];
[failure release];
}
}
-(void)alertView: (UIAlertView *)success clickedButtonAtIndex: (NSInteger)buttonIndex{
switch(buttonIndex) {
case 0: {
[self.navigationController popToRootViewControllerAnimated:YES];
}
}
}
因此,在這兩種情況下,他們按照上面的動作,但顯然,這不是我想要的。關於我在這裏做什麼的任何想法?
我不知道,但幾乎任何事情都比你擁有的更好。毛。 – Pyrolistical 2010-04-07 22:34:18
這是怎麼回事? – bear 2010-04-07 22:36:12
這裏有什麼問題?這是關於格式化代碼還是關於alertviews? – 2010-04-07 22:51:38