ViewController Appears to Transition Twice

前端 未结 4 1616
孤街浪徒
孤街浪徒 2021-02-10 05:23

Problem Summary

My mainVC --> second VC transtion appears to run twice. However, what\'s odd is that the second VC\'s viewDidLoad only runs once. This i

相关标签:
4条回答
  • 2021-02-10 05:42

    One reason might be that the controller which is being pushed have another transition in its viewWillAppear() method.

    In my case, I had put textField.becomesFirstResponder() in viewWillAppear() method which triggers keyboard to show

    Move any such method to viewDidAppear()

    0 讨论(0)
  • 2021-02-10 05:43

    I had ALMOST the same problem and my second VC was sliding twice. The problem was with that segue arrow in my Main.storyboard. I control-dragged from a button in first VC and not from my VC (that little yellow circle on top of every VC), so I deleted that segue arrow and control-dragged from VC yellow circle to my second VC and it fixed the problem.

    Also this is how I used performSegue function:

    @IBAction func toSignUp(_ sender: Any) {
        performSegue(withIdentifier: "signUp", sender: nil)
    }
    

    Hope this was helpful.

    0 讨论(0)
  • 2021-02-10 05:45

    I found Elena's answer (on this thread Pushing View Controller Twice) to be a time saving quick fix by simply checking if the navigation controller already contains the ViewController you want to push to.

    if !(self.navigationController!.viewControllers.contains(editView)){
    self.navigationController?.pushViewController(editView, animated:true)
    

    }

    0 讨论(0)
  • 2021-02-10 05:49

    Essentially you simply need to rename the destination view controller's class.

    For full answer see this post:

    View Controller Loads Twice - How Do I Fix It?

    0 讨论(0)
提交回复
热议问题