我打开了一个登录模式UIViewController,然后在60秒钟内模态显示第二个“谢谢” Viewcontroller,然后关闭它,但是我可以弄清楚如何在SWIFT中执行此操作。 (在Objectiv C中很容易)
这是我的代码,用于在关闭第一个代码后打开“Thank you viewcontroller”。
weak var pvc = self.presentingViewController
self.dismiss(animated: true, completion: {
let thankYouExistingVC = self.storyboard?.instantiateViewController(identifier: "ThankYouExistingVC") as! ThankYouExistingVC
pvc?.present(thankYouExistingVC, animated: true, completion: nil)
})
最佳答案
您可以使用DisaptchQueue
来做到这一点:
DispatchQueue.main.asyncAfter(deadline: .now() + 60) {
// Do whatever you want
theViewControllerToDismiss.dismiss(animated:true, completion: nil)
}
关于ios - X秒后关闭模态ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59967814/