When my application is interrupted, for example, when I receive a phone call, lock the screen or switch applications, I need it to react differently, depending on which view / view on the screen is displayed during the interrupt.
in my first view controller, we will call it VCA, I have it
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doSomething) name:UIApplicationWillResignActiveNotification object:NULL]; -(void)doSomething{
In VCB, I have
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doSomethingElse) name:UIApplicationWillResignActiveNotification object:NULL]; -(void)doSomethingElse{
but if VCB is on the screen or any subsequent controller of the form (vcc, vcd, vce) and the screen is locked, it will only respond to the doSomething method defined in VCA. Even if I don't have UIApplicationWillResignActiveNotification in one of the view controllers that comes after the VCA, it will still respond to the doSomethign method defined in the VCA.
Is there any way to make the application react differently, depending on what kind of view is on the screen when it goes into the background?
source share