我有这个代码:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
}
else if(buttonIndex == 1)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Danger"
message:@"war"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
}
但是每次我按下这个 UIAlert 的 ok 时,它都会在这个委托(delegate)方法中返回;我该如何解决这个问题?我可以使用 BOOL 进行控制吗?
最佳答案
将第二个 alertView
的委托(delegate)设置为 nil。
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Danger"
message:@"war"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
但是,如果您希望在将来为第二个添加选项,您可以为 alertView
设置一个 tag
值并检查调用的标签委托(delegate)方法。根据 tag
值,您将执行不同的任务。
关于objective-c - IOS:停止 UIAlert 循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6202148/