在我的课堂上,我需要有2个不同(或更多)的动作表。所有工作表都转到willPresentActionSheet。在willPresentActionSheet中,我会添加一个datepicker。但是我怎么知道哪个动作表叫做willPresentActionSheet?
编辑:我创建了这样的动作表:
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];
答案 0 :(得分:6)
您可以为操作表设置“标记”,并使用willPresentActionSheet:
方法检查标记。简单!
修改强> 设置标记。
actionSheet1.tag = 100;
actionSheet2.tag = 101;
并使用willPresentActionSheet:
方法。
if (actionSheet.tag == 100) {
// actionSheet1 is going to be presented
} else if (actionSheet.tag == 101) {
// actionSheet2 is going to be presented
}
答案 1 :(得分:1)
它将动作表传递给方法......所以,如果你有(在标题中声明)actionView1和actionView2那么你可以做...
if([actionSheet isEqual:actionView1]) {
// do stuff for 1
} else if([actionSheet isEqual:actionView2]) {
// do stuff for 2
}