-(void)alertViewCancel:(UIAlertView*)alertView呼び出されることはありません
-
20-09-2019 - |
質問
私の問題をUIAlertViewDelegate方法 -(void)alertViewCancel:(UIAlertView*)alertView 呼び出されることはありませんが私をキャンセルAlertViewでcancelボタンを押します。
かの委譲方法 -(void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex コンビニエンスストアでのお支.
いて考えたんですか?
かまいません。
Sean
- (void)alertViewCancel:(UIAlertView *)alertView
{
if(![self aBooleanMethod])
{
exit(0);
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
//some code
}
私はこのボタンがクリックす:
- (void)ImagePickDone
{
UIAlertView *alertDone = [[UIAlertView alloc]
initWithTitle:@"Done"
message:@"Are u sure?"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles: @"Yes", nil];
[alertDone show];
[alertDone release];
}
解決
のalertViewCancelを使用する際のシステム免トビューしない場合、ユーザーが"Cancel"ボタンを押します。見積もりから apple docs:
オプションを実装する事が出来ます alertViewCancel:方法の 適切な時にアクションシステム 解除アラート。の場合 委譲はこの実施 の方法では、デフォルトの動作は シミュレーのユーザクリックしない場合はキャンセル ボタンを閉じる。
いる場合は、ユーザーが"Cancel"ボタンを使用するのはclickedButtonAtIndex法のことを確認する指標に対応する指数でない場合はキャンセルボタンを押します。を得るプラグインベースのアーキテクチ用
index = alertDone.cancelButtonIndex;
他のヒント
を処理することができますわない場合はキャンセルのインデックス0のこのdelegate:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0){
//cancel button clicked. Do something here.
}
else{
//other button indexes clicked
}
}
この改善には二つの方法があります。第一に、のみを取り扱う場合にユーザーが実際にクリックするボタンを押します。な取扱いの状況[myAlert dismissWithClickedButtonIndex:]と呼ばれ、その警報は解散の一部。第二に、ボタンを0でない場合はキャンセルボタンを押します。にアラートとボタンのインデックスは0、右インデックスは1です。変更された場合、それぞれのタイトルの右ボタンと"Cancel"、ボタン1が論理的にキャンセルボタンを押します。の代わりに"willDismiss"実践できる"didDismiss"の後に呼ばれる、ダイアログが無くなってしまったいない。
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == alertView.cancelButtonIndex)
{
//cancel button clicked. Do something here.
}
else
{
//other button indexes clicked
}
}