这是我的现有代码。 我正在尝试在按下按钮时添加音效。
#import <AudioToolbox/AudioToolbox.h>
- (void)threeBombExplosion
{
NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"3Explosions" ofType:@"mp3"];
NSURL *threeExplosionsURL = [NSURL fileURLWithPath:soundPath];
AudioServicesCreateSystemSoundID(CFBridgingRetain(threeExplosionsURL),&_threeExplosionsID);
}
我正在调用这个函数以使其执行(UIButton Action)。
AudioServicesPlaySystemSound(_threeExplosionsID);