In my class I need to have 2 different (or more) actionsheets. All of the sheets go to willPresentActionSheet. In willPresentActionShee开发者_如何学Got I do things like add a datepicker. But how do I know which actionsheet called the willPresentActionSheet?
EDIT: I created the actionsheet like this:
UIActionSheet *asheet = [[UIActionSheet alloc]
initWithTitle:@"Pick a value"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Select"
, nil];
[asheet showInView:[self.view superview]];
[asheet setFrame:CGRectMake(0, 117, 320, 383)];
[asheet release];
You can set the 'tag' for the action sheets, and check the tag in willPresentActionSheet:
method. Simple!
Edit: Set the tag.
actionSheet1.tag = 100;
actionSheet2.tag = 101;
And in willPresentActionSheet:
method.
if (actionSheet.tag == 100) {
// actionSheet1 is going to be presented
} else if (actionSheet.tag == 101) {
// actionSheet2 is going to be presented
}
It passes the actionsheet into the method... So if you have (declared in the header) actionView1 and actionView2 then you can do...
if([actionSheet isEqual:actionView1]) {
// do stuff for 1
} else if([actionSheet isEqual:actionView2]) {
// do stuff for 2
}
精彩评论