2011-06-03 25 views
0

我在我的应用程序中使用下面的代码来发出嘟嘟声。它在我的系统iPad模拟器(4.2和4.3)中工作。但它不会在我的iPad iOs 4.2中发出哔哔声。在iPad中发出蜂鸣声的问题?

我的代码是:

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

请注意,设备中的文件名称区分大小写。 – EmptyStack 2011-06-03 08:53:15

+0

好的..我使用audioplayer与相同的url.it工作正常在我的ipad.but我不知道为什么这不工作 – Christina 2011-06-03 09:00:19

回答

1

没有什么错在你的代码。仍尝试使用以下代码。来自我的一个工作项目。

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

希望它有效。