我试过这段代码但没有用,
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"paying with coins and bills" ofType:@"wav"];
AudioServicesCreateSystemSoundID(CFBridgingRetain([NSURL fileURLWithPath:soundPath]), &(soundID));
AudioServicesPlaySystemSound (soundID);
}
它只会在我运行 xcode 项目时播放。
我的要求是,在我的 ipad 中,每当打开我的应用程序时,我都需要播放声音。请帮我