【发布时间】:2017-07-09 10:14:57
【问题描述】:
我正在尝试解雇一个 VC 并提出一个新的 VC。但我不希望旧的 VC 存在了。我使用下面的代码来关闭当前的 VC 并呈现新的。但是这样,在解雇和出席之间有一个时间间隔。我不希望用户注意到这一点。所以,我想先介绍新的 VC,然后再驳回之前的 VC。有没有办法做到这一点?
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) -
朋友,您为什么要从堆栈中删除该 currentVc?
-
直接你可以通过将动画设为假来关闭。
-
@AndreasOetjen 如果我这样做,它首先会提出并解雇新的 VC,而不是旧的 VC
-
@Mukesh 因为我不想在用户再次返回时再次显示它。以及将动画设为 false 对我有何帮助?
标签: ios swift dismiss presentviewcontroller