gpt4 book ai didi

ios - 尝试在 Swift 中使用警报操作切换到另一个 View Controller

转载 作者:行者123 更新时间:2023-11-28 05:32:39 27 4
gpt4 key购买 nike

在我的代码中,我有一个允许用户登录或注册的操作表。当用户按下其中任何一个时,我想定义一个处理程序,将它们连接到登录/注册 View Controller 。我对此很陌生,所以我不太确定我做错了什么,但在我的代码中我收到一个错误,指出类型不可转换。代码如下所示:

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)

关于ios - 尝试在 Swift 中使用警报操作切换到另一个 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27107938/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com