0

如何在警报本地通知显示时立即运行命令 NSLog(@"Alert display...")?...我正在 iphone 中创建一个闹钟,我想在那个时候播放音乐(在警报本地通知显示)!我将使用 AVPlayer 在 iphone 中播放来自 ipod 库的音乐!但我做不到。你能帮助我吗!谢谢!

4

1 回答 1

0

如果您的应用程序处于后台并暂停,则在弹出 LocalNotification 时您无法执行代码。您可以做的是将您的音乐文件分配给 soundName 属性,但请注意您的声音不得超过 30 秒。这是代码:

UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.soundName = @"yourMusicFile.caf";

当然,如果您的应用没有暂停,您可以使用 AVAudioPlayer 播放音乐...

于 2012-07-25T08:54:06.373 回答