【发布时间】:2011-11-16 17:01:30
【问题描述】:
我正在创建一个非常简单的应用程序。 2个按键,都播放声音。每个剪辑持续 1 秒并响应“TouchUpInside”。它们是我在 iTunes 中转换的 .caf 文件。
这是我的代码,再一次,它可以在模拟器上运行,但不能在设备上运行:
enter code here- (void)viewDidLoad {
NSLog(@"InView did load");
AudioServicesCreateSystemSoundID ((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"bigaif" ofType:@"caf"]], &systemSoundID);
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource: @"smallwav" ofType:@"wav"]],
&systemSoundIDTwo);
}
-(IBAction) playSound:(id) sender {
AudioServicesPlaySystemSound(systemSoundID);
}
-(IBAction) playSoundTwo:(id) sender {
AudioServicesPlaySystemSound(systemSoundIDTwo);
}
【问题讨论】:
-
文件名没有问题?面对 mac 设置为 casemapping 并且由于文件名中的拼写错误是同样的情况
-
嗯,我自己想出来的。我想发布解决方案,这样其他人就不会犯这个错误。使用“系统声音”时,请确保在设置中打开了系统声音。
标签: xcode ipad ios4 avaudioplayer ios-simulator