我想推送到另一个视图控制器,但是当您按下该按钮几次时,它将推送到视图控制器两次或更多次。如何防止推多次发生。
DispatchQueue.main.async {
let vc: MyOrderDetailsViewController? = self.storyboard?.instantiateViewController(withIdentifier: "orderDetailsVC") as? MyOrderDetailsViewController
self.navigationController?.pushViewController(vc!, animated: true)
}
答案 0 :(得分:-1)
异步方法创建线程&在后台推送VC,所以不要使用Async方法推送任何视图控制器......
它将按您按下的时间运行您的代码,而不是使用以下代码..这将不允许您再次单击或重新运行相同的代码,直到它完成任务..
func pushTap()
{
let vc: MyOrderDetailsViewController? = self.storyboard?.instantiateViewController(withIdentifier: "orderDetailsVC") as? MyOrderDetailsViewController
self.navigationController?.pushViewController(vc!, animated: true)
}
希望这有帮助..谢谢