"cancelButtonTitle:@"Cancel"" および "otherButtonTitles:nil" で AlertView を完全に動作させています。私の質問は、他のボタンを取得する方法です。
「otherButtonTitles:@"2nd Button"」のみを変更すると、iPhone シミュレーターがアプリからホーム画面にクラッシュします。
"cancelButtonTitle:@"Cancel"" および "otherButtonTitles:nil" で AlertView を完全に動作させています。私の質問は、他のボタンを取得する方法です。
「otherButtonTitles:@"2nd Button"」のみを変更すると、iPhone シミュレーターがアプリからホーム画面にクラッシュします。
次のようにメソッド呼び出しを終了します。
...cancelButtonTitle:@"Cancel" otherButtonTitles:@"Button1Title", @"Button2Title", nil];
これは、引数のリストが任意の長さにできる String フォーマットで見られるのと同じパターンです。通常、引数リストは nil で終了します。ゼロを忘れないでください。
ケビンが言ったのとまったく同じですが、その補足として、ターゲットアクションを他のボタンに割り当てることもできます。
をインスタンス化するときは、引数をUIAlertView
に設定し、次のメソッドをオブジェクトに追加します。delegate
self
-(void) alertView: ( UIAlertView *) alertView
clickedButtonAtIndex: ( NSInteger ) buttonIndex {
// do stuff
// if you want the alert to close, just call [ alertView release ]
}
`