iOS 6 - viewDidUnload migrate to didReceiveMemoryWarning?

前端 未结 5 1843
遥遥无期
遥遥无期 2020-11-30 20:41

So with viewDidUnload deprecated as of iOS 6, what do I need to do now?

Delete it, and migrate all of it\'s contents in didReceiveMemoryWarning

5条回答
  •  无人及你
    2020-11-30 21:38

    If you need to know if your UIViewController is dismissing you can add this code to your viewWillDisappear:

    - (void)viewWillDisappear:(BOOL)animated
    {
        [super viewWillDisappear:animated];
    
        if ([self isBeingDismissed] || [self isMovingFromParentViewController])
        {
            // Do your viewDidUnload stuff
        }
    }
    

    It is not called at the same time as viewDidUnload did once in the view controller life cycle, but works in most cases for your needs!

提交回复
热议问题