Cocoa:在app最前面强制NSUserNotification

Cocoa:在app最前面强制NSUserNotification,第1张

概述相当简单,我有一个应该发送通知的应用程序,但如果应用程序是最前面的,它将不会这样做.从NSUserNotificationCenter类参考: The user notification center reserves the right to decide if a delivered user notification is presented to the user. For example 相当简单,我有一个应该发送通知的应用程序,但如果应用程序是最前面的,它将不会这样做.从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).

从我可以收集的内容来看,它与userNotificationCenter:shouldPresentNotification:NSUserNotificationCenterDelegate协议参考中显示的方法有关,但我无法弄清楚如何实现它.我已经将我的课程设置为NSUserNotificationCenterDelegate,所以不是这样.

有任何想法吗?

编辑:
在我设置为NSUserNotificationCenterDelegate的类中,我使用它来尝试覆盖原始方法,如果应用程序位于最前面,则默认为NO:

- (BOol)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {return YES;}

但没有任何反应.

解决方法 NSUserNotificationCenter * center = [NSUserNotificationCenter defaultUserNotificationCenter];
[中心时间表通知:通知];
center.delegate = self;

>(BOol)userNotificationCenter 总结

以上是内存溢出为你收集整理的Cocoa:在app最前面强制NSUserNotification全部内容,希望文章能够帮你解决Cocoa:在app最前面强制NSUserNotification所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1004214.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存