如何制作祝酒词,然后在同一按钮上更改屏幕单击ios swift

如何制作祝酒词,然后在同一按钮上更改屏幕单击ios swift,ios,swift,toast,Ios,Swift,Toast,当用户点击register(注册)按钮,然后引导用户进入登录屏幕时,我试图展示一个祝酒词,如下所示: print("Registration Successful") self.view.makeToast("Registration Successful") let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("LoginViewController") as! Logi

当用户点击register(注册)按钮,然后引导用户进入登录屏幕时,我试图展示一个祝酒词,如下所示:

  print("Registration Successful")
  self.view.makeToast("Registration Successful")
  let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
  self.navigationController?.pushViewController(nextViewController, animated: true)

但这里的问题是屏幕变化很快,因此很难阅读祝酒词。我想展示“成功”祝酒词,然后更改屏幕。有人能帮我吗

好吧,iOS不支持祝酒,所以你必须使用某种库。我猜它不支持完成处理程序,所以最直接的方法是等待片刻,然后显示下一个视图控制器

let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(2 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
    self.view.hideToast()
    let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
    self.navigationController?.pushViewController(nextViewController, animated: true)
}
// it waits for 3 seconds and then presents the next view controller
let delay = Int64(3 * Double(NSEC_PER_SEC))
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay), dispatch_get_main_queue()) { 
    let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
    self.navigationController?.pushViewController(nextViewController, animated: true)
}

嗯,iOS不支持祝酒,所以你必须使用某种库。我猜它不支持完成处理程序,所以最直接的方法是等待片刻,然后显示下一个视图控制器

// it waits for 3 seconds and then presents the next view controller
let delay = Int64(3 * Double(NSEC_PER_SEC))
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay), dispatch_get_main_queue()) { 
    let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
    self.navigationController?.pushViewController(nextViewController, animated: true)
}
试试这个

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5.0 * NSEC_PER_SEC), dispatch_get_current_queue(), {() -> Void in
 let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
self.navigationController?.pushViewController(nextViewController, animated: true)
})
试试这个

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 5.0 * NSEC_PER_SEC), dispatch_get_current_queue(), {() -> Void in
 let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
self.navigationController?.pushViewController(nextViewController, animated: true)
})

您可以在2秒钟后按ViewController。您可以在2秒钟后按ViewController。