- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
从 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
”
但现在关闭按钮的 react 基本上与 actionButton
的 react 方式相同??
最佳答案
NSUserNotification 具有您可以管理通知标识符或 hasActionButton 值的属性,因此您可以在同一委托(delegate)方法中使用 if else 处理关闭按钮与操作按钮
- (void) userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification{
}
关于objective-c - NSUserNotification 关闭调用 didActivateNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46610367/
目前,当我使用 Alert 样式创建 NSUserNotification 时,除非我手动关闭它,否则它不会隐藏。 有没有办法可以在 2 秒后自动关闭/隐藏它? NSUserNotification
我的 NSUserNotification 会在我的应用程序中发生某些事情时显示以记录。即使应用程序是最前面的应用程序(即始终显示它),是否有任何方法可以显示通知? (如果我在其他应用程序中,它确实会
NSUserNotification如果用户在系统首选项中将我的应用程序的通知样式设置为“警报”,则仅显示操作按钮。我可以以某种方式为我的应用程序将此样式设置为默认样式,而不是依赖用户手动选择它吗?
相当简单,我有一个应用程序应该发送通知,但如果该应用程序位于最前面,它就不会这样做。来自 NSUserNotificationCenter 类引用: The user notification cen
我刚刚注意到 iTunes 的通知图标被专辑封面取代了: 它的应用程序图标是标题附近的一个小图标,与我所知道的有点不同: 我只能添加图像作为内容的一部分,而不能添加应用程序图标。 是否存在我不知道的未
我正在使用此代码: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code
我目前正在制作一个使用以下代码显示通知的 XIB 菜单栏应用程序: func showNotification(message:String, title:String = "App Name") -
我是 OSX 开发的新手,我正在制作一个应用程序,当发生某些事情时会触发通知。但是当应用程序是关键应用程序时它不会显示通知,因为这是默认行为。即使应用程序是关键应用程序,我也想向他们展示。然而,我只找
在“通知”设置 Pane 中,用户可以指定是否希望单个应用程序将通知显示为警报、横幅或无。我的应用程序中的一些通知可以用作其中之一,但有些只是快速错误消息,不需要用户交互,因此我希望这些通知始终是横幅
我想编写一个仅显示 NSUserNotification 的命令行工具程序。我发现,为了显示 NSUserNotification,我需要创建一个 Cocoa 应用程序,但这不是我想要的。 我想在后台
我正在尝试更新已发送通知(警报)的副标题中的字符串,我使用 NSTimer 执行此操作,如下所示: [NSTimer scheduledTimerWithTimeInterval:5.0
在上图中,您可以在 OS X 上看到两个通知。第一个来 self 的应用程序,第二个来自 Apple 的 Reminders.app。在图像中,您可以看到 otherButtonTitle“完成”和
我想在应用程序显示在最前面时显示用户通知。我找到了下面的代码,但我不确定如何使用委托(delegate):它似乎只返回一个 bool 值。 class MyNotificationDelegate:
有没有办法确定某个 NSUserNotification 是否仍在屏幕上或已被关闭?我还没有找到执行此操作的方法。 最佳答案 我想你可以使用 NSUserNotificationCenterDeleg
我在网上搜索过,但找到的唯一方法是循环 - (void)userNotificationCenter:(NSUserNotificationCenter *)center didDeliverNoti
在 10.9 中,NSUserNotification 支持一个新属性“contentImage”,它允许在通知本身中使用图形。我真的希望有一种方法可以取代 iTunes 通知的通知屏幕,这样发件人/
我正在使用 NSUserNotification 来显示通知。这工作正常。问题是当您点击通知时: 应用通知不会从通知中心删除。 应用(最小化时)打不开。 熟悉 NSUserNotification 的
有人知道从应用程序发送的系统通知标题栏中的标题使用的是哪个值吗? 假设我的应用名为“My.app Name”, header 标题仅显示“My”。 我说的是这个领域: 尝试在build设置中更改产品名
我正在使用这个方法: NSUserNotification *notification = [[NSUserNotification alloc] init]; notific
让我先描述一下场景,然后再描述问题: 我创建了一个使用 NSUserNotification 显示用户通知的函数 -(void)notify:(NSString*) message {
我是一名优秀的程序员,十分优秀!