- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
有没有人设法让 NSUserNotification soundName 与自定义声音一起工作?我尝试使用 aif 和 caf 格式 44100KHz 16bit 2 秒的持续时间。通知在适当的时间显示,带有正确的标题和文本,但播放的是默认声音而不是我的自定义声音。
声音文件已正确复制到应用程序包中。如果我尝试这个声音工作正常:
NSSound* sound = [NSSound soundNamed:@"morse.aif"];
[sound play];
但是当我在通知中使用相同的声音时,会播放默认的通知声音:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSUserNotification* notification = [[NSUserNotification alloc]init];
notification.title = @"Titolo";
notification.deliveryDate = [NSDate dateWithTimeIntervalSinceNow:10];
notification.soundName = @"morse.aif";
[[NSUserNotificationCenter defaultUserNotificationCenter]scheduleNotification:notification];
}
我试过带扩展和不带扩展,但都没有成功。
notification.soundName = @"morse.aif";
notification.soundName = @"morse2.caf";
notification.soundName = @"morse";
这些都不起作用。
我的应用程序没有签名,也没有沙盒化,但我认为这对于用户通知来说不是必需的,除了声音问题之外,通知效果很好。
最佳答案
在我看来,这个问题是区分大小写的。使用 notification.soundName = @"Morse";
非常适合我。正如您在 NSSound
documentation 中看到的那样对于 soundNamed
声音的搜索文件夹依次为:
~/Library/Sounds
/Library/Sounds
/Network/Library/Sounds
/System/Library/Sounds
如果你查看最后一个,这可能是你试图从中提取的,因为它们是系统偏好设置中的声音,你可以看到它们的名字
所以保留文件的大小写,省略扩展名,它应该可以按预期工作。
关于objective-c - 具有自定义 soundName 的 NSUserNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12267357/
目前,当我使用 Alert 样式创建 NSUserNotification 时,除非我手动关闭它,否则它不会隐藏。 有没有办法可以在 2 秒后自动关闭/隐藏它? NSUserNotification
我的 NSUserNotification 会在我的应用程序中发生某些事情时显示以记录。即使应用程序是最前面的应用程序(即始终显示它),是否有任何方法可以显示通知? (如果我在其他应用程序中,它确实会
NSUserNotification如果用户在系统首选项中将我的应用程序的通知样式设置为“警报”,则仅显示操作按钮。我可以以某种方式为我的应用程序将此样式设置为默认样式,而不是依赖用户手动选择它吗?
相当简单,我有一个应用程序应该发送通知,但如果该应用程序位于最前面,它就不会这样做。来自 NSUserNotificationCenter 类引用: The user notification cen
我刚刚注意到 iTunes 的通知图标被专辑封面取代了: 它的应用程序图标是标题附近的一个小图标,与我所知道的有点不同: 我只能添加图像作为内容的一部分,而不能添加应用程序图标。 是否存在我不知道的未
我正在使用此代码: - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code
我目前正在制作一个使用以下代码显示通知的 XIB 菜单栏应用程序: func showNotification(message:String, title:String = "App Name") -
我是 OSX 开发的新手,我正在制作一个应用程序,当发生某些事情时会触发通知。但是当应用程序是关键应用程序时它不会显示通知,因为这是默认行为。即使应用程序是关键应用程序,我也想向他们展示。然而,我只找
在“通知”设置 Pane 中,用户可以指定是否希望单个应用程序将通知显示为警报、横幅或无。我的应用程序中的一些通知可以用作其中之一,但有些只是快速错误消息,不需要用户交互,因此我希望这些通知始终是横幅
我想编写一个仅显示 NSUserNotification 的命令行工具程序。我发现,为了显示 NSUserNotification,我需要创建一个 Cocoa 应用程序,但这不是我想要的。 我想在后台
我正在尝试更新已发送通知(警报)的副标题中的字符串,我使用 NSTimer 执行此操作,如下所示: [NSTimer scheduledTimerWithTimeInterval:5.0
在上图中,您可以在 OS X 上看到两个通知。第一个来 self 的应用程序,第二个来自 Apple 的 Reminders.app。在图像中,您可以看到 otherButtonTitle“完成”和
我想在应用程序显示在最前面时显示用户通知。我找到了下面的代码,但我不确定如何使用委托(delegate):它似乎只返回一个 bool 值。 class MyNotificationDelegate:
有没有办法确定某个 NSUserNotification 是否仍在屏幕上或已被关闭?我还没有找到执行此操作的方法。 最佳答案 我想你可以使用 NSUserNotificationCenterDeleg
我在网上搜索过,但找到的唯一方法是循环 - (void)userNotificationCenter:(NSUserNotificationCenter *)center didDeliverNoti
在 10.9 中,NSUserNotification 支持一个新属性“contentImage”,它允许在通知本身中使用图形。我真的希望有一种方法可以取代 iTunes 通知的通知屏幕,这样发件人/
我正在使用 NSUserNotification 来显示通知。这工作正常。问题是当您点击通知时: 应用通知不会从通知中心删除。 应用(最小化时)打不开。 熟悉 NSUserNotification 的
有人知道从应用程序发送的系统通知标题栏中的标题使用的是哪个值吗? 假设我的应用名为“My.app Name”, header 标题仅显示“My”。 我说的是这个领域: 尝试在build设置中更改产品名
我正在使用这个方法: NSUserNotification *notification = [[NSUserNotification alloc] init]; notific
让我先描述一下场景,然后再描述问题: 我创建了一个使用 NSUserNotification 显示用户通知的函数 -(void)notify:(NSString*) message {
我是一名优秀的程序员,十分优秀!