我正在研究一个快速的os x应用程序,我无法理解userNoticiation / didActivateNotification结构.我查看了文档并搜索了SO但仍然卡住了.我们非常感谢您对以下代码的任何指导:
func notify(message: String,callBack: String) { println(message) println(callBack) var notification:NSUserNotification = NSUserNotification() notification.title = "New Phone Call" notification.informativeText = message notification.actionButtonTitle = "Lookup" notification.hasActionButton = true var center:NSUserNotificationCenter = NSUserNotificationCenter.defaultUserNotificationCenter() center.delegate = self center.scheduleNotification(notification) } func notify (center: NSUserNotificationCenter,didActivateNotification notification: NSUserNotification){ center.delegate = self println("clicked") //this does not print }
通知显示完全符合我的要求.单击我定义的“查找”按钮会在第一次单击时将我的应用程序带到前台,但是我希望处理该操作的代码不会触发.
提前致谢.
将您的第二个’func notify’声明更改为’optional func userNotificationCenter’
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。