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
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()
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.
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)
}
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?