我在这里有一个小问题。我在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