检测其他按钮单击(NSUserNotification) [英] Detect Other Button click (NSUserNotification)
问题描述
我已经搜索过互联网,但唯一的方法是循环使用
I've searched all over the internet but the only method found was by looping through
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didDeliverNotification:(NSUserNotification *)notification
,如下所示:http://stackoverflow.com/a/21365269/1795083
但是,我的应用程序有时会在很短的时间间隔显示多个通知,所以这不是真的高效也不有效。当按下垃圾桶按钮时,邮件应用程序如何处理它。必须至少有一个被调用的私有方法。有没有人遇到过?提前感谢
However, my app sometimes displays multiple notifications at a short interval, so this isn't really efficient nor effective. How does the mail app handle it when the trash button is pressed. There has to be at least a private method that's called. Has anyone ever came across it? Thanks in advance
推荐答案
After ... uhm ....检查邮件应用程式的程式码...我找到在其通知控制器类中的可疑函数...
After... uhm.... "checking" out the mail app's code... I found a suspicious function in their notification controller class...
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didDismissAlert:(NSUserNotification *)alert
我不知道为什么苹果不想将这个函数添加到NSUserNotificationDelegate。 ..但我测试了这在我的应用程序,它的工作原理!!!
I have no idea why apple don't want to add this function to the NSUserNotificationDelegate... but I tested this out in my app and it works!!!
这篇关于检测其他按钮单击(NSUserNotification)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!