objective c - Why are the view*Disappear methods not being called in iOS? -
i try when home button , power button has been clicked. developing in ios.
this code use:
- (void)viewdiddisappear:(bool)animated{ [super viewdiddisappear:animated]; nslog(@"viewdiddisappear"); } - (void)viewwilldisappear:(bool)animated{ [super viewwilldisappear:animated]; nslog(@"viewwilldisappear"); } - (void)applicationfinishedrestoringstate{ nslog(@"applicationfinishedrestoringstate"); }
why above function not being called when click power button or home button on iphone?
did miss something?
viewdiddisappear:
, viewwilldisappear:
called if view pushed or popped or in anyway gets disappeared in own runloop, going background pressing home or power button doesn't count view' related events, rather app related events. should register uiapplicationwillresignactivenotification
notification instead.
e.g.
[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(disappearselector) name:uiapplicationwillresignactivenotification object:nil];
Comments
Post a Comment