Present a view controller, dismiss it and present a different one in Swift
The error occurs because you are trying to present SecondController from FirstController after you have dismissed FirstController. This doesn’t work: self.dismiss(animated: true, completion: { let vc = SecondController() // ‘self’ refers to FirstController, but you have just dismissed // FirstController! It’s no longer in the view hierarchy! self.present(vc, animated: true, completion: nil) }) This problem … Read more