我有一个这样的操作表:
- (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