问题描述
我一直在寻找了几个小时的解决方案。与绝对的零运气。
I have been searching for a solution for hours.. with absolutely zero luck.
我成立了一个本地通知:
I set up a Local Notification:
UILocalNotification *notif = [[cls alloc] init];
[dateComp setDay:j+1];
[dateComp setHour:[[time objectAtIndex:0] integerValue]+offset];
[dateComp setMinute:[[time objectAtIndex:1] integerValue]];
NSLog(@"Year: %i, Month: %i, Day: %i, Time:%i:%i\n",[dateComp year], [dateComp month],
[dateComp day], [dateComp hour], [dateComp minute]);
notif.fireDate = [gregorian dateFromComponents:dateComp];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = [names objectAtIndex: k];
notif.soundName = @"fireburn.caf";
注意声音名称...
Notice the sound name...
我试图把10的声音(AIFF,WAV,CAF ...等),但只是通知弹出的默认声音:/
I tried to put 10 sounds (aiff, wav, caf...etc), but the notification just pops up with the default sound :/
我在资源文件夹中的fireburn.caf文件。
I have the "fireburn.caf" file in the Resources folder.
为什么不打我的声音?????
Why is it not playing my sound?????
感谢。
推荐答案
答:
没有错code ..
Nothing wrong with the code..
这只是愚蠢的iPhone并没有取消,我的默认声音发旧的通知 - _ 的 - ;
It's just that the stupid iPhone didn't cancel the old notifications that I made with the default sound -_-;
当我清理项目,从手机中删除的应用,然后重新启动手机,它的工作。
When I cleaned the project, deleted the app from the phone AND REBOOTED the phone THEN it worked..
希望有人认为这很有帮助。
Hope someone finds this helpful.
这篇关于UILocalNotification自定义音效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!