UILocalNotification自定义声音

Maz*_*yod 8 iphone audio nsbundle ios4 uilocalnotification

我一直在寻找一个解决方案几个小时..绝对没有运气.

我设置了本地通知:

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";
Run Code Online (Sandbox Code Playgroud)

注意声音名称......

我尝试放10个声音(aiff,wav,caf ...等),但通知只是弹出默认声音:/

我在Resources文件夹中有"fireburn.caf"文件.

为什么不播放我的声音?????

谢谢.

Maz*_*yod 10

回答:

代码没什么问题..

只是愚蠢的iPhone没有取消我使用默认声音发出的旧通知 - _ - ;

当我清理项目时,从手机中删除了应用程序并重新启动手机然后它工作了..

希望有人觉得这很有帮助.

  • 如果有人仍然在努力解决这个问题,我发现可能还需要做一件事.当将音频文件拖放到项目中时,除了选中"复制..."之外,您可能还需要检查"添加到目标"选项.这对我有用.无论如何,谢谢你的回答. (3认同)