![](/img/trans.png)
[英]iOS 4.3, iPhone 4 not playing custom sound with UILocalNotification
[英]How to change custom sound in UILocalNotification in iphone?
我在ios的uilocalnotification中使用自定义声音。 但它没有发挥。 文件存在于Document文件夹中。 通知正在使用local.soundName= UILocalNotificationDefaultSoundName;
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *path = [NSString stringWithFormat:@"%@/DingDongTone.wav",documentsPath];
local.soundName=path;
请帮忙。 谢谢。
请重新阅读苹果所说的内容 -
对于此属性,请指定应用程序主bundle或
UILocalNotificationDefaultSoundName
声音资源的文件名(包括扩展名)以请求默认系统声音。 当系统显示本地通知的警报或标记应用程序图标时,它会播放此声音。 默认值为nil
(无声音)。 不支持持续时间超过30秒的声音。 如果您指定的声音播放时间超过30秒,则会播放默认声音。
根据此filename
是不在document directory
的main bundle
资源中的文件path
注意:文件也不应超过
30 sec.
@saadnib
说我完全同意他sound resource should in the application's main bundle
specify the filename
sound resource should in the application's main bundle
specify the filename
(包括扩展名)
所以在应用程序的主程序包中复制你的声音,然后不要forget to copy
你的path string
,它应该工作。
yourLocalNotification.soundName= [yourSoundFilePath copy];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.