Cocoa 检测关闭按钮点击NSUserNotification
我正在用以下代码在OS X上显示本地NSUserNotification:Cocoa 检测关闭按钮点击NSUserNotification,cocoa,button,notifications,nsusernotification,nsusernotificationcenter,Cocoa,Button,Notifications,Nsusernotification,Nsusernotificationcenter,我正在用以下代码在OS X上显示本地NSUserNotification: NSUserNotification *notification = [[NSUserNotification alloc] init]; [notification setTitle:@"Some Title"]; [notification setHasActionButton:YES]; [notification setActionButtonTitle:@"Snooze"]; NSUserNotificati
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被解除或单击close(关闭)按钮,是否有办法获得通知?单击关闭按钮时,不会触发NSUserNotificationCenter的userNotificationCenter:didActivateNotification:
如果这是不可能的,有没有办法创建一个下拉按钮,就像苹果在其提醒应用程序中使用的那样(如果用户按住操作按钮,就会打开一个菜单)
谢谢 可能重复的