- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
相当简单,我有一个应用程序应该发送通知,但如果该应用程序位于最前面,它就不会这样做。来自 NSUserNotificationCenter 类引用:
The user notification center reserves the right to decide if a delivered user notification is presented to the user. For example, it may suppress the notification if the application is already frontmost (the delegate can override this action).
据我所知,它与 NSUserNotificationCenterDelegate 协议(protocol)引用中显示的 userNotificationCenter:shouldPresentNotification:
方法有关,但我不知道如何实现它。我已经将我的类设置为 NSUserNotificationCenterDelegate,所以不是这样。
有什么想法吗?
编辑:在我设置为 NSUserNotificationCenterDelegate 的类中,我使用它来尝试覆盖原始方法,如果应用程序位于最前面,则默认为 NO:
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {
return YES;
}
但是什么也没发生。
最佳答案
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];[中心日程通知:通知];center.delegate = self;
关于Cocoa:当应用程序位于最前面时强制执行 NSUserNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12102601/
我是一名优秀的程序员,十分优秀!