我想在我的iphone上播放系统声音,声音在模拟器中播放得非常好,但在设备上无法正常工作.
- (IBAction)SystemSound:(id)sender {
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"waterfall" ofType:@"caf"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)soundFileURL, &systemSound);
AudioServicesPlaySystemSound(systemSound);
}
Run Code Online (Sandbox Code Playgroud)