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.

Frank
  • 3,073
  • 5
  • 40
  • 67
  • 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. – rckoenes May 26 '14 at 14:28
  • 7
    `applicationDidEnterBackground` should not be called at all when the notification/control center appears - `applicationWillResignActive` is called in this case – mspensieri May 26 '14 at 15:19
  • 2
    `applicationDidEnterBackground` also will not be called when you receive a phone call. – rckoenes May 26 '14 at 18:50

1 Answers1

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.

Aaron
  • 269
  • 3
  • 11