iOS 6 - viewDidUnload migrate to didReceiveMemoryWarning?

前端 未结 5 1829
遥遥无期
遥遥无期 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:28

    In most typical cases, this method can be used in place of the old viewDidUnload.

    // The completion handler, if provided, will be invoked after the dismissed controller's viewDidDisappear: callback is invoked.
    - (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion NS_AVAILABLE_IOS(5_0);
    

    Swift 2017 syntax:

    override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
        if (yourChildViewController  != nil) {
          print("good thing we did this!")
        }
        yourChildViewControllerProperty = nil
        super.dismiss(animated: flag, completion: completion)
    }
    

提交回复
热议问题