2011-08-15 76 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的声音 - 打开系统首选项,然后选择声音。在那里取消选中,然后重新检查'播放用户界面的声音效果' - 这有助于解决我的类似问题。