次のコードを使用して、OS X でローカルの NSUserNotification を表示しています。
NSUserNotification *notification = [[NSUserNotification alloc] init];
[notification setTitle:@"Some Title"];
[notification setHasActionButton:YES];
[notification setActionButtonTitle:@"Snooze"];
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
[center setDelegate:self];
[center scheduleNotification:notification];
私が直面している問題は、通知自体または「アクション ボタン」のいずれかがクリックされた場合にのみメッセージが表示されることですが、「その他の」ボタン (閉じるボタン) がクリックされた場合にもいくつかのコードを実行したいということです。NSUserNotification が却下された場合、または閉じるボタンがクリックされた場合に通知を受け取る方法はありますか? userNotificationCenter:didActivateNotification:
閉じるボタンをクリックしても、NSUserNotificationCenterはトリガーされません。
それが不可能な場合、Apple がリマインダー アプリケーションで使用するようなドロップダウン ボタンを作成する方法はありますか (ユーザーがアクション ボタンを押したままにすると、メニューが開きます)。
ありがとう!