Home > DeveloperSection > Forums > Why viewWillDisappear or viewDidDisappear not called when app quit in iOS simulator?
Sunil Singh
Sunil Singh

Total Post:11

Points:77
Posted on    April-20-2015 4:13 AM

 iPhone iPhone  Ios 
Ratings:


 1 Reply(s)
 766  View(s)
Rate this:

I'm trying to call removeObserver() when the app quits. But when I used NSLog() to check, I found neither viewWillDisappear() nor viewDidDisappear() was called after the app quit in iOS simulator. I'm using a single view template, not navigation controller in similar questions.



Jayden Bell
Jayden Bell

Total Post:105

Points:739
Supported
Posted on    April-20-2015 4:19 AM

These two methods will not be called when you quit the app. Instead, the method you can use observer


 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(applicationDidEnterBackground:)name:UIApplicationDidEnterBackgroundNotification object:nil];

(void)applicationDidEnterBackground:(NSNotification *)aNotification {
 // your  removeObserver code goes here.
    NSLog(@"applicationDidEnterBackground");

}


Don't want to miss updates? Please click the below button!

Follow MindStick