我们如何检测iOS 7上的控制中心? [英] How do we detect when control center on iOS 7?

查看:176
本文介绍了我们如何检测iOS 7上的控制中心?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当控制中心出现在iOS 7上时出现问题。基本上,当控制中心出现时会触发applicationDidEnterBackground。

I am having an issue when the control center appears on iOS 7. Basically, the applicationDidEnterBackground is fired when the control center appears.

但是在我的方法中,我想检测它是否只是控制中心的开放或通知中心,因为我会在该状态下对applicationDidEnterBackground采取不同的处理方式。

However in my method, I would like to detect if it's just the control center opening or the notification center since I would treat the applicationDidEnterBackground differently in that state.

任何帮助都将不胜感激。

Any help would be appreciated.

推荐答案

我刚刚发布了一个小UIWindow子类这正是如此。您只需订阅NSNotification并可以对打开控制中心的用户做出反应。 Github上的详细说明和设置: AAWindow

I just published a little UIWindow subclass that does exactly that. You simply subscribe to an NSNotification and can react to the user opening Control Center. Detailed instructions and setup on Github: AAWindow.

实现这一目标的方法是在UIWindow中使用NSTimer和覆盖sendEvent的组合来接收所有触摸而不阻止它们。所以你基本上接收所有触摸检查它们是否接近屏幕的下边缘,如果是设置定时器半秒,并且如果在此定时器运行期间调用applicationWillResignActive,则几乎可以肯定ControlCenter已打开。如果没有状态栏,则时间必须变化,因为此时应用程序处于全屏状态,并且用户最多可以花3秒钟启动控制中心。

The way this is accomplished is by using a combination of NSTimer and overwriting sendEvent in UIWindow to receive all touches without blocking them. So you basically receive all touches check if they are near the lower edge of the screen, if yes set a timer for a half a second and if during this timer is running applicationWillResignActive is called you can be almost certain that ControlCenter is opened. The time has to vary if there's no statusbar, because then the app is in fullscreen and it can take the user up to 3 seconds to launch Control Center.

这篇关于我们如何检测iOS 7上的控制中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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