I am trying to show a toast when the user hits the register button and then direct the user to the login screen as follows:
print("Registration Successful")
self.view.makeToast("Registration Successful")
let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController
self.navigationController?.pushViewController(nextViewController, animated: true)
But the problem here is that screen changes quickly due to which the toast can hardly be read. I would like to show the "Successful" toast and then change the screen. Can someone help me with it.
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)
}