Search code examples
iosobjective-cstatusbarnsnotificationcenter

Detect touch action that involves status bar


I have to perform action when user returns from expanded status bar. What I can do: 1. User touches status bar. using this code

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(onStop)
                                                 name:UIApplicationWillResignActiveNotification
                                               object:nil];

How to detect this action: 2. Returning from status bar? This method doesn't work

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(onStart)
                                                 name:UIApplicationWillEnterForegroundNotification
                                               object:nil];

Any solution?


Solution

  • Found solution.

    Use UIApplicationDidBecomeActiveNotification

    instead of

    UIApplicationWillEnterForegroundNotification .