簡體   English   中英

NSUserNotification狀態

[英]NSUserNotification state

有沒有辦法確定某個NSUserNotification是否仍在屏幕上或已被解雇? 我還沒有辦法做到這一點。

我想你可以使用NSUserNotificationCenterDelegate_Protocol

它具有userNotificationCenter:didActivateNotification:當用戶單擊用戶通知中心提供的用戶通知時發送給代理

但請記住,它還取決於使用的通知類型。 如果是“橫幅”,那么它可能會在用戶點擊之前消失。

因此,與代理人一起,您還必須檢查通知的類型以及是否已提交。

更新:我沒有使用過NotificationCenter。 所以沒有代碼可以交給你。 但也看一下常數:

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.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM