Reputation: 165
I have an action sheet which works like this:
- (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];
}
then in my delegate i have:
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex: NSInteger)buttonIndex {
if (actionSheet.tag==1) {
if (buttonindex==2) {
[self method2];
}
} else if (actionSheet.tag==2) {
// some code
}
}
My delegate method gets called for the first action sheet i.e. photoSourceSheet but not for photoSourceSheet1.
Is there something special I need to do, like manually dismissing the sheet?
My second UIActionSheet
(photoSourceSheet1) appears but it crashes the app as soon as I select an option on the sheet.
It throws EXEC_BAD_ACCESS
Upvotes: 0
Views: 567
Reputation: 112
There is nothing wrong with the above code. EXEC_BAD_ACCESS is basically due to ill Memory Management.Sometimes you unintentionally remove the object that is being used. Try enable Zombies it will tell you the exact problem area.
Steps: Go to Edit Scheme Memory Management Check the option enable Zombie Objects
Upvotes: 1