iPad发出哔哔声的问题?

时间:2011-06-03 08:44:26

标签: iphone objective-c

我在我的应用程序中使用以下代码发出哔声。它在我的系统iPad模拟器(4.2和4.3)中工作。但它没有在我的iPad iOs 4.2中发出哔哔声。

我的代码是:

NSURL *tapSound = [[NSBundle mainBundle] URLForResource:@"BEEPJAZZ" withExtension: @"WAV"];   
self.soundFileURLRef = (CFURLRef) [tapSound retain];    
AudioServicesCreateSystemSoundID (soundFileURLRef,&soundFileObject);
AudioServicesPlayAlertSound (soundFileObject);

1 个答案:

答案 0 :(得分:1)

您的代码没有任何问题。仍尝试使用以下代码。来自我的一个工作项目。

NSString *tapSoundPath = [[NSBundle mainBundle] pathForResource:@"BEEPJAZZ" ofType:@"WAV"];
self.soundFileURLRef = (CFURLRef) [NSURL fileURLWithPath:tapSoundPath];
AudioServicesCreateSystemSoundID(knifeSoundUrl, &soundFileObject);  
AudioServicesPlayAlertSound (soundFileObject);

希望它有效。

相关问题