我有一个行动清单,它是这样工作的:
- (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];
}然后,在我的委托中,我有:
- (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
发布于 2012-10-17 03:41:48
上面的代码没有任何错误。EXEC_BAD_ACCESS基本上是由于内存错误Management.Sometimes你无意中删除了正在使用的对象。尝试启用僵尸,它会告诉你确切的问题区域。
步骤:转到编辑方案内存管理选中选项启用僵尸对象
https://stackoverflow.com/questions/12921460
复制相似问题