WHY VIEWWILLDISAPPEAR OR VIEWDIDDISAPPEAR NOT CALLED WHEN APP QUIT IN IOS SIMULATOR?

Sunil Singh

Total Post:38

Points:274
Posted by  Sunil Singh
iPhone  Ios 
 1271  View(s)
Ratings:
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.

  1. Jayden Bell

    Post:110

    Points:774
    Re: Why viewWillDisappear or viewDidDisappear not called when app quit in iOS simulator?

    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");

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!