UINavigationControllerDelegate‘s didShowViewController method was called twice

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

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


        
3条回答
  •  悲&欢浪女
    2021-02-19 15:39

    I hit the same issue in my code. I was able to work around it by waiting until viewDidAppear to set the navigation delegate instead of setting it in viewDidLoad. To translate it to your example:

    override func viewDidLoad() {
       super.viewDidLoad()
    }
    
    // ...
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        navigationController!.delegate = self
    }
    

提交回复
热议问题