When using a UINavigationController the viewWillAppear or viewDidAppear methods of my controller are not called

后端 未结 6 1825
眼角桃花
眼角桃花 2020-12-30 06:21

Here is the pitch.

  • I have a UIViewController subclass which does something in its viewWillAppear and viewDidAppear methods.
  • I want to nest this view c
6条回答
  •  攒了一身酷
    2020-12-30 06:51

    The above solution not works for me. My case is the custom view controller nested under a complex UINavigationController not gets called viewWillAppear and viewDidAppear. Use below in custom view controller:

    beginAppearanceTransition(true, animated: animated)  // Tells a child controller its appearance is about to change. Do not invoke viewWillAppear(_:), viewWillDisappear(_:), viewDidAppear(_:), or viewDidDisappear(_:) directly.
    endAppearanceTransition() // Tells a child controller its appearance has changed.
    

提交回复
热议问题