How do we detect when control center on iOS 7?
Asked Answered
N

1

2

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.

Nieshanieto answered 26/5, 2014 at 14:25 Comment(3)
Guess you are out of luck, applicationDidEnterBackground is the only to detect if the control center is shown. There is no specific information whether it is a phone call, notification or control center is shown.Artieartifact
applicationDidEnterBackground should not be called at all when the notification/control center appears - applicationWillResignActive is called in this caseBly
applicationDidEnterBackground also will not be called when you receive a phone call.Artieartifact
C
4

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.

Carisa answered 19/3, 2015 at 12:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.