UINavigationControllerDelegate‘s didShowViewController method was called twice

后端 未结 3 1162
情深已故
情深已故 2021-02-19 15:01
class ViewController: UIViewController, UINavigationControllerDelegate {

      override func viewDidLoad() {
         super.viewDidLoad()
         navigationController!         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-19 15:40

    The UINavigationController has displayed two instances of a UIViewController

    From the UINavigationControllerDelegate documentation

    Called just after the navigation controller displays a view controller’s view and navigation item properties.

    Instead of logging "showViewController", log the UIViewController instance to see what's going on

    func navigationController(navigationController: UINavigationController, didShowViewController viewController: UIViewController, animated: Bool) {
         print(viewController)
    }
    

提交回复
热议问题