在幻灯片上停止UILocalNotification声音以查看 [英] Stop UILocalNotification Sound on slide to view

查看:91
本文介绍了在幻灯片上停止UILocalNotification声音以查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的闹钟应用程序中,我正在安排一段时间的闹钟。

In my alarm app, I am scheduling an alarm on some time.

随着应用程序在前台我锁定我的iPhone(iOS7,我还没试过iOS6)。

With the app in foreground I lock my iPhone (iOS7, I haven't tried with iOS6).

现在,当通知声音开始时,我使用锁定屏幕上的幻灯片查看查看本地通知,当应用程序打开时,我也可以使用 AVAudioPlayer 播放声音。

Now when the notification sound starts, I view the local notification by using the "Slide to view" on my lock screen, and when the app opens, I also play the sound using AVAudioPlayer.

所以问题是通知声音持续响铃直到30.0秒。

So the problem is notification sound continuously ringing until 30.0 seconds.

这是iOS问题还是代码我需要整合任何方法等。

Is this iOS issue or in the code I need to integrate any method etc.?

谢谢

推荐答案

根据其他 SO帖子,这是iOS 7的一个错误,当用户'滑到时,声音不会停止查看'如果密码锁已关闭。

according to another SO post, this is a bug with iOS 7 where the sound doesn't stop when the user 'slides to view' if passcode lock is turned off.

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

possible fixes can include turning on passcode lock or using this code (taken from the linked post).

 - (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开始修复此错误

这篇关于在幻灯片上停止UILocalNotification声音以查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆