1

モーダルビューがフレームワーク(私の場合はイベントキット)から提示される場合、キャンセルまたは完了ボタンが押されたかどうかを検出する正しい方法は何でしょうか。私のモーダルビューの例ではdidCompleteWithaction、モーダルビューが閉じられ、アラートビューが起動されます。Doneキャンセルボタンではなく、ボタンが押された場合にのみアラートビューを表示したい。

私の最初の考えはif、完了ボタンが押されたときのステートメントでしたが、完了ボタンのプロパティを取得する方法がわかりません。

- (void)eventEditViewController:(EKEventEditViewController *)controller
      didCompleteWithAction:(EKEventEditViewAction)action {

// Dismiss the modal view controller
[controller dismissModalViewControllerAnimated:YES];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"message" message:@"Added to calender" delegate:nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];

[alert show];


}
4

2 に答える 2

1

デリゲートのプロトコル リファレンスを見てください: Apple のドキュメント

actionユーザーが選択したアクションを表すため、デリゲート メソッドのパラメーターを確認する必要があります。

例えば

- (void)eventEditViewController:(EKEventEditViewController *)controller
      didCompleteWithAction:(EKEventEditViewAction)action {

// Dismiss the modal view controller
[controller dismissModalViewControllerAnimated:YES];

//this checks what action the user chose:
if (action == EKEventEditViewActionSaved) {
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"message" message:@"Added to calender" delegate:nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];

     [alert show];
     }


}

「完了」ボタンによってどのアクションがトリガーされるかはわかりませんが、おそらく ...ActionSaved ですが、自分で確認してください。

于 2013-01-01T15:44:23.237 に答える
1

私はかなり外れているかもしれませんが、actionパラメーターはあなたが望むものではありませんか?

EKEventEditViewAction

ユーザーが編集を終了するために行ったアクションを説明します。

typedef enum {
   EKEventEditViewActionCanceled,
   EKEventEditViewActionSaved,
   EKEventEditViewActionDeleted
} EKEventEditViewAction;

EKEventEditViewActionSavedDoneボタンに対応するべきだ と思います。

于 2013-01-01T15:45:32.520 に答える