在我的代码中,我有一个允许用户登录或注册的操作表。当用户按下其中任何一个时,我想定义一个处理程序,将它们转换为登录/注册视图控制器。我对此很新,所以我不太确定我做错了什么但是在我的代码中我得到的错误是类型不可转换。代码如下所示:
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)
}
任何帮助将不胜感激!提前致谢。
答案 0 :(得分:2)
我不知道segues但我通常只是这样介绍它们:
let loginVC = LoginViewController()
self.presentViewController(loginVC, animated: true, completion: nil)