我想要关闭一个视图控制器并呈现一个新的视图控制器,但我不希望旧的视图控制器继续存在。我使用下面的代码来关闭当前的视图控制器和呈现新的视图控制器。但是这种方式在关闭和呈现之间会有一段时间间隔。我不希望用户注意到这一点。因此,我想先呈现新的视图控制器,然后再关闭以前的视图控制器。有没有办法做到这一点?
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let destinationController = self.storyboard?.instantiateViewController(withIdentifier: "login") as! Login
let presentingVC = self.presentingViewController
self.dismiss(animated: false, completion: { () -> Void in
presentingVC!.present(destinationController, animated: true, completion: nil)
})
presentingVC!.present(destinationController, animated: true, completion: nil); self.dismiss(animated: false, completion:nil)
- Andreas Oetjen