在iPhone中点击按钮时出现“点击声音”问题

时间:2011-09-29 04:43:20

标签: iphone objective-c ios xcode4

我正在项目中工作,我面临按钮点击播放点击声的问题,我已经在每页的按钮上的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设备上测试时,它会发出嗡嗡声,但不能播放咔嗒声,所以有人可以指出它之所以如此吗? 感谢

1 个答案:

答案 0 :(得分:0)

您确定在获得TouchUpEvent时停止播放声音吗?

相关问题