これは、1 つのコントローラーが複数のシートを表示する場合ですが、各シートにどのボタンが表示されるかを知っていますか? その場合は、シートのタグ プロパティを使用してそれらを区別できます。
- (IBAction)showEditSheet:(id)sender {
UIActionSheet * sheet = [[UIActionSheet alloc] initWith...];
sheet.tag = 1;
[sheet showInView:self.view];
}
- (IBAction)showDeleteSheet:(id)sender {
UIActionSheet * sheet = [[UIActionSheet alloc] initWith...];
sheet.tag = 2;
[sheet showInView:self.view];
}
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
switch(actionSheet.tag) {
case 1:
// This is the edit sheet
switch(buttonIndex) { ... }
break;
case 2:
// This is the delete sheet
switch(buttonIndex) { ... }
break;
default:
NSAssert(NO, @"Unknown action sheet");
}
}