我正在使用这段代码:
- (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];
}
我一定会得到,
没有操作按钮或其他按钮。
正如之前的答案中所述,需要将通知类型设置为提醒要显示的操作按钮。如果你想设置你的应用程序的默认通知样式来提醒,你需要定义键NSUserNotificationAlertStyle在 info.plist 中使用值alert.
参见苹果的info.plist 键参考 http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1更多细节:
NSUserNotificationAlertStyle指定通知样式是否应为banners, alerts, or none。默认值为banner,这是推荐的样式。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)