首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >uiactionsheet崩溃

uiactionsheet崩溃
EN

Stack Overflow用户
提问于 2012-10-17 02:48:46
回答 1查看 556关注 0票数 0

我有一个行动清单,它是这样工作的:

代码语言:javascript
复制
- (void)Method1 {
    UIActionSheet *photoSourceSheet=[[UIActionSheet alloc]
                                     initWithTitle:@"Options"
                                     delegate:self
                                     cancelButtonTitle:@"Exit"
                                     destructiveButtonTitle:nil
                                     otherButtonTitles:@"opt1",@"opt2", @"opt3", nil];
    photoSourceSheet.tag=1;
    photoSourceSheet.delegate=self;
    [photoSourceSheet showInView:self.view];
}

- (void)Method2 {
    UIActionSheet *photoSourceSheet1=[[UIActionSheet alloc]
                                      initWithTitle:@"Select Video"
                                      delegate:self
                                      cancelButtonTitle:@"Cancel"
                                      destructiveButtonTitle:nil
                                      otherButtonTitles:@"Take New Video", @"Choose Existing Video", nil];
    //   photoSourceSheet.delegate=self;
    photoSourceSheet1.tag=2;
    photoSourceSheet1.delegate=self;
    [photoSourceSheet1 showInView:self.view];
}

然后,在我的委托中,我有:

代码语言:javascript
复制
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex: NSInteger)buttonIndex {
    if (actionSheet.tag==1) {
        if (buttonindex==2) {
            [self method2];
        }
    } else if (actionSheet.tag==2) {
        // some code
    }
}

我的委托方法是为第一个动作单(即photoSourceSheet )调用的,但不是为photoSourceSheet1调用的。是否有什么特殊的事情需要我去做,比如手动关闭工作表?我的第二个UIActionSheet (photoSourceSheet1)会出现,但只要我在工作表上选择一个选项,它就会使应用程序崩溃。它抛出EXEC_BAD_ACCESS

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-17 03:41:48

上面的代码没有任何错误。EXEC_BAD_ACCESS基本上是由于内存错误Management.Sometimes你无意中删除了正在使用的对象。尝试启用僵尸,它会告诉你确切的问题区域。

步骤:转到编辑方案内存管理选中选项启用僵尸对象

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12921460

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档