この方法で iPad に UIActionSheet を表示しています。
_actionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose action"
delegate:(id<UIActionSheetDelegate>)self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
if (special_case) {
_actionSheet.destructiveButtonIndex = [_actionSheet addButtonWithTitle:@"Discard Action"];
}
[_actionSheet addButtonWithTitle:@"Action One"];
[_actionSheet addButtonWithTitle:@"Action Two"];
_actionSheet.cancelButtonIndex = [_actionSheet addButtonWithTitle:@"Cancel"];
[_actionSheet showFromBarButtonItem:self.myActionButton animated:YES];
両方とも正常cancelButtonIndex
にdestructiveButtonIndex
動作しますが、奇妙なことは、actionSheet:didDismissWithButtonIndex: にfirstOtherButtonIndex
設定されていることです。これは、ボタンのインデックスがであるのに対し、インデックスが である-1
ため、明らかに間違っています。Action One
1
Action Two
2
明らかに、上記の全体的なポイントは、特別な場合にのみ破壊的なボタンを表示することです (そうでなければ、init 呼び出しですべてのタイトルを渡し、おそらく物事はうまくいったでしょう)。
私は何が欠けていますか?