2011-08-15 72 views
1

我試圖在應用程序啓動後一分鐘安排UILocalNotification。這是我使用的代碼,UILocalNotification聲音未播放

-(void)scheduleNotification{ 

    UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 

    localNotif.timeZone = [NSTimeZone defaultTimeZone]; 
    localNotif.fireDate = [NSDate dateWithTimeIntervalSinceNow:60]; 

    localNotif.alertBody = @"Test"; 
    localNotif.alertAction = @"View"; 
    localNotif.soundName=UILocalNotificationDefaultSoundName; 

    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 
    [localNotif release]; 
} 

alertView在適當的時間後顯示,但沒有播放聲音。 我錯過了什麼?

在此先感謝

編輯 我在模擬器上測試它現在

+0

可能出現[顯示UIAlertView時播放本地通知默認聲音?](http://stackoverflow.com/questions/3277811/play-local-notification-default-sound-when-displaying-uialertview) –

+0

,您可能想看看這個:http://stackoverflow.com/questions/23532706/why-doesnt-my-uilocalnotification-play-any-sound – frank

回答

0

嘗試重新設置您的Mac的聲音 - 打開系統首選項,然後選擇聲音。在那裏取消選中,然後重新檢查'播放用戶界面的聲音效果' - 這有助於解決我的類似問題。