gpt4 book ai didi

cocoa - NSUserNotification 不显示操作按钮

转载 作者:行者123 更新时间:2023-12-03 16:00:39 25 4
gpt4 key购买 nike

我正在使用此代码:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSUserNotification *notification = [[NSUserNotification alloc] init];
[notification setTitle: @"Title"];
[notification setSubtitle: @"Subtitle"];
[notification setInformativeText: @"Informative Text"];

[notification setHasActionButton: YES];
[notification setActionButtonTitle: @"Action Button"];
[notification setOtherButtonTitle: @"Other Button"];

[notification setSoundName: NSUserNotificationDefaultSoundName];

[notification setDeliveryDate: [NSDate dateWithTimeIntervalSinceNow: 10]];
[[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification: notification];
}

而且我毫无疑问地得到了,

enter image description here

没有操作按钮或其他按钮。

最佳答案

正如之前的回答中所述,需要将通知类型设置为提醒要显示的操作按钮。如果您想将应用程序的默认通知样式设置为提醒,则需要在 info.plist 中定义键 NSUserNotificationAlertStyle ,并将值设置为 alert

请参阅 Apple 的 info.plist keys reference了解更多详情:

NSUserNotificationAlertStyle Specifies whether the notification style should be banners, alerts, or none. The default value is banners, which is the recommended style.

关于cocoa - NSUserNotification 不显示操作按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11676017/

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