加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – UIAlertview代码上的EXC_BAD_ACCESS = 1

发布时间:2020-12-14 20:03:38 所属栏目:百科 来源:网络整理
导读:我在[alert show]行上获得了EXC_BAD_ACCESS. 为什么我得到这个? alert = [[UIAlertView alloc]initWithTitle:@"Application Alert" message:@"all date popup" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Update",nil]; [alert show]; //EXC
我在[alert show]行上获得了EXC_BAD_ACCESS.

为什么我得到这个?

alert = [[UIAlertView alloc]initWithTitle:@"Application Alert" message:@"all date popup" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Update",nil];

 [alert show]; //EXC_BAD_ACCESS on this line

解决方法

只需要委托nil,不要将自己委托给代理.如下所示

alert = [[UIAlertView alloc]initWithTitle:@"Application Alert" message:@"all date popup" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Update",nil];

[alert show];

如果您在委托中使用self,则必须使用alert delegate方法

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

然后它不会给EXC_Bad_Excess.let我知道它是否有效.. !!!!快乐编码….

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读