objective c - How to respond to applicationWillResignActive differently from different View Controllers -


when application interrupted, such receiving phone call, screen locked, or switching applications, need respond differently depending on view/viewcontroller on screen @ time of interruption.

in first view controller, we'll call vca, have this

              [[nsnotificationcenter defaultcenter]  addobserver:self  selector:@selector(dosomething)  name:uiapplicationwillresignactivenotification   object:null];      -(void)dosomething{     //code here     }; 

in vcb have

    [[nsnotificationcenter defaultcenter]  addobserver:self  selector:@selector(dosomethingelse)  name:uiapplicationwillresignactivenotification   object:null];      -(void)dosomethingelse{ //code here }; 

but if vcb on screen, or subsequent view controller (vcc, vcd, vce), , screen locked, respond dosomething method defined in vca. if don't have uiapplicationwillresignactivenotification in 1 of view controllers comes after vca, still respond dosomethign method defined in vca.

is there way can make application respond differently depending on view on screen when goes background?

this works me in applicationdidenterbackground

if ([navigationviewcontroller.visibleviewcontroller iskindofclass:[yourclass class]]) {     //your code } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - EclipseLink JPA Object is not a known entity type -

java - Need to add SOAP security token -