在我的代码中,我有一个操作表,允许用户登录或注册。当用户按下其中任意一个时,我想定义一个处理程序,将其选择到登录/注册视图控制器中。我对此很陌生,所以我不太确定自己在做什么错,但是在我的代码中我得到一个错误,指出类型不可转换。代码如下:
let actionSheet = UIAlertController(title: "Do you have an account?", message: "Please Log-In or Sign-Up", preferredStyle: .ActionSheet)
if let presentationController = actionSheet.popoverPresentationController {
presentationController.sourceView = sender as UIView
presentationController.sourceRect = sender.bounds
}
let dismissHandler = {
(action: UIAlertAction!) in
self.dismissViewControllerAnimated(true, completion: nil)
}
let signupHandler = ({
(ViewController: UIViewController!) in
let signupVC: nextViewController = segue.signupVC as nextViewController
})
let loginHandler = ({
(ViewController: UIViewController!) in
let loginVC: nextViewController = segue.loginVC as nextViewController
})
actionSheet.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: dismissHandler))
actionSheet.addAction(UIAlertAction(title: "Log-In", style: .Default, handler: dismissHandler))
actionSheet.addAction(UIAlertAction(title: "Sign-Up", style: .Default, handler: signupHandler))
presentViewController(actionSheet, animated: true, completion: nil)
}
任何帮助将不胜感激!提前致谢。
我不知道segues,但是我通常只是这样介绍它们:
let loginVC = LoginViewController()
self.presentViewController(loginVC, animated: true, completion: nil)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句