自从MacOS 10.13每次我点击 NSUserNotification
上的关闭按钮后,它调用:
- (void) userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
如何防止这种情况或处理 close
与 action
按钮
要创建通知我做:
NSUserNotification *notification = [[NSUserNotification alloc] init];
...
[notification setHasActionButton:false];
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:(id)self];
并且 .plist
中的 NSUserNotificationAlertStyle
设置为“ alert
”
但现在基本上关闭按钮的反应方式与 actionButton
相同?
2 回答
NSUserNotification具有可以管理通知标识符或hasActionButton值的属性,因此您可以使用if else在同一委托方法中处理关闭与操作按钮的关系
这对我有用..
您可以在
didActivateNotification:
方法中删除通知哪里
center
是......