2011-04-06 192 views
2

基本上,當我的應用程序上的按鈕被觸摸時,播放音頻。很簡單,但它卻無法在我的實際設備上工作,但在模擬器中運行良好。當按鈕被觸摸時,執行該功能:音頻將在iPhone模擬器中播放,但不會在設備上播放

- (IBAction)playButtonSound 
{ 
    SystemSoundID buttonSound; 
    NSURL *tapSound = [[NSBundle mainBundle] URLForResource: @"Button_Sound" withExtension: @"caf"]; 
    CFURLRef buttonSoundURLRef = (CFURLRef) [tapSound retain]; 
    AudioServicesCreateSystemSoundID (buttonSoundURLRef, &buttonSound); 
    AudioServicesPlaySystemSound(buttonSound); 
    [tapSound release]; 
} 

我還是一個新手iPhone,所以我不能完全肯定這種情況的原因是什麼。

回答

0

您的設備上是否禁用了系統聲音?顧名思義,如果用戶禁用了系統聲音,則通常不會播放AudioServicesPlaySystemSound。有一個屬性kAudioServicesPropertyIsUISound,應該可以設置爲NO來禁用此行爲。

+0

我不這麼認爲。 是的,我檢查了文件名,他們是正確的。 – Robbeh 2011-04-06 03:03:51

相關問題