ios - 在幻灯片上停止 UILocalNotification Sound 以查看

标签 ios iphone objective-c ipad uilocalnotification

在我的闹钟应用中,我安排了某个时间的闹钟。

应用程序在前台时,我锁定了我的 iPhone(iOS7,我还没有尝试过 iOS6)。

现在,当通知声音开始时,我在锁定屏幕上使用“滑动查看”来查看本地通知,当应用程序打开时,我还使用 AVAudioPlayer 播放声音。

所以问题是通知声音一直响到 30.0 秒。

这是 iOS 问题还是在我需要集成任何方法等的代码中?

谢谢

最佳答案

根据 another所以帖子,这是 iOS 7 的一个错误,如果密码锁定已关闭,当用户“滑动查看”时声音不会停止。

可能的修复方法包括打开密码锁或使用此代码(取自链接帖子)。

 - (void)applicationWillEnterForeground:(UIApplication *)application
{
   AVAudioSession *session = [AVAudioSession sharedInstance];
   [session setCategory:AVAudioSessionCategoryPlayback error:nil];
   [session setActive:YES error:nil];
   MPMusicPlayerController *musicPlayer = [MPMusicPlayerController applicationMusicPlayer];
    [musicPlayer setVolume:0.0f]; 
}

此错误已从 iOS 8 开始修复

关于ios - 在幻灯片上停止 UILocalNotification Sound 以查看,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24340423/

相关文章:

iphone - 如何使按钮的文字向左对齐?

iphone - 检查 iOS 中 Safari 的内存使用情况

ios - 在屏幕上移动 UIImage

android - 访问整个 Xamarin 应用程序的文件夹

ios - 通过公共(public)方法访问私有(private)接口(interface)属性

iphone - UIAlertView 开始显示,屏幕变暗,但直到为时已晚才弹出!

objective-c - UIRefreshControl:刷新时 UITableView 'stuck'

objective-c - 与 NSWindowController 窗口 socket 作斗争

ios - 当子类化 UIView 并将其添加到界面构建器中时,不会调用 drawRect

ios - iOS 13 中弹出窗口的阴影消失了