有人发现这有什么问题吗?我有一个 UIAltertView,但当我单击两个按钮中的任何一个时,会收到 EXC_BAD_ACCESS:
UIAlertView *alert = [[UIAlertView alloc] init];
[alert setTitle:@"First Sync"];
[alert setMessage:@"The App is going to do its first synchronisation. This might take a few moment..."];
[alert setDelegate:self];
[alert addButtonWithTitle:@"OK"];
[alert addButtonWithTitle:@"Cancel"];
[alert show];
[alert release];
并捕获响应:
#pragma mark UIAlertView
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex != 0)
{
NSLog(@"TEST1");
return;
}
NSLog(@"TEST2");
}
这一定是简单的事情......
最佳答案
您必须使用指定的初始值设定项:
initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:
关于cocoa-touch - 无法让 UIAlert 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4985821/