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

Total Post:24

Posted on    April-20-2015 4:13 AM

 iPhone iPhone  Ios 

 1 Reply(s)
 1173  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:110

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.


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

Follow MindStick