gpt4 book ai didi

objective-c - NSUserNotification 状态

转载 作者:搜寻专家 更新时间:2023-10-30 20:25:56 26 4
gpt4 key购买 nike

有没有办法确定某个 NSUserNotification 是否仍在屏幕上或已被关闭?我还没有找到执行此操作的方法。

最佳答案

我想你可以使用 NSUserNotificationCenterDelegate_Protocol

它有userNotificationCenter:didActivateNotification:当用户点击用户通知中心显示的用户通知时发送给委托(delegate)。

但请记住,这还取决于所使用的通知类型。如果是“横幅”,则它可能会在用户点击之前消失。

因此,与委托(delegate)一起,您还必须检查通知的类型以及它是否已呈现。

更新:我没有使用过通知中心。所以手头没有代码。但也要看看常量:

NSUserNotificationActivationType
These constants describe how the user notification was activated.

enum {
NSUserNotificationActivationTypeNone = 0,
NSUserNotificationActivationTypeContentsClicked = 1,
NSUserNotificationActivationTypeActionButtonClicked = 2
}
typedef NSInteger NSUserNotificationActivationType;
Constants
NSUserNotificationActivationTypeNone
The user did not interact with the notification alert.
Available in OS X v10.8 and later.
Declared in NSUserNotification.h.
NSUserNotificationActivationTypeContentsClicked
The user clicked on the contents of the notification alert.
Available in OS X v10.8 and later.
Declared in NSUserNotification.h.
NSUserNotificationActivationTypeActionButtonClicked
The user clicked on the action button of the notification alert.
Available in OS X v10.8 and later.
Declared in NSUserNotification.h.

关于objective-c - NSUserNotification 状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12017986/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com