【发布时间】:2011-11-27 09:31:56
【问题描述】:
我正在从事的项目中遇到了在单击按钮时播放单击声音的问题,我已经在每个页面上的按钮的 TouchDown 事件中完成了以下代码
-(IBAction)ClickButtonSound:(id)sender
{
SystemSoundID theSound;
NSString *pathToSound;
pathToSound = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"buttonsound" ofType:@"wav"] isDirectory:NO];
OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)pathToSound,&theSound);
NSLog(@"error=%@",error);
AudioServicesPlaySystemSound (theSound);
//[pathToSound release];
}
这段代码在模拟器上运行良好,但是当我在 iphone 设备上测试它时,它会发出嗡嗡声,但不会播放点击声,所以任何人都可以指出为什么会这样吗? 谢谢
【问题讨论】:
标签: iphone objective-c ios xcode4