UINavigationControllerDelegate‘s didShowViewController method was called twice

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

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


        
3条回答
  •  耶瑟儿~
    2021-02-19 15:32

    didShowViewController is called twice because the first time it is called when the navigation controller transitions to showing the view controller. And then it is called again by the navigation controller's own viewDidAppear when it appears on screen, using the topViewController as the controller param which in this case is the same as the controller the first time it was called.

提交回复
热议问题