How do we detect when control center on iOS 7?

笑着哭i 提交于 2020-01-04 08:26:18

问题


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

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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/23872338/how-do-we-detect-when-control-center-on-ios-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!