我正在实现一个非常简单的 iOS 应用程序,只是为了练习在其中显示弹出警报,当我按下警报按钮时出现错误:
线程 1:EXC_BAD_ACCESS(代码=1,地址=0x676f6f57)
这是代码:
- (IBAction)AlertButton {
alert = [[UIAlertView alloc]
initWithTitle:@"Alert" message:@"Alert"
delegate:self
cancelButtonTitle:@"Dismiss"
otherButtonTitles:@"Apple", "Google" ,nil];
[alert show];}
-(void)alertView :(UIAlertView *)alertView clickedButttonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex == 1){
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://apple.com"]];
}
if(buttonIndex == 2){
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://google.com"]];
}}