gpt4 book ai didi

ios - 为什么要执行我的 segue?

转载 作者:搜寻专家 更新时间:2023-11-01 06:18:28 25 4
gpt4 key购买 nike

在我的 iOS 应用程序中,我有一个登录 Button 以从一个 viewController 转到另一个,它使用以下函数:

@IBAction func logInButton(sender: AnyObject) {
if loggedIn == true {
// user is signed in
print("A user is logged in.")
uid = user.uid
self.currentUser(uid)
self.performSegueWithIdentifier("logIn", sender: sender)
} else {
print("No current user.")
let anim = CAKeyframeAnimation( keyPath:"transform" )
anim.values = [
NSValue( CATransform3D:CATransform3DMakeTranslation(-10, 0, 0 ) ),
NSValue( CATransform3D:CATransform3DMakeTranslation( 10, 0, 0 ) )
]
anim.autoreverses = true
anim.repeatCount = 2
anim.duration = 7/100
self.passwordTextField.layer.addAnimation( anim, forKey:nil )
self.welcomeTextLabel.hidden = false
self.welcomeTextLabel.text = "Please sign in first"
}
}

viewDidLoad() 中运行的函数会更新 loggedIn 值。我已经在 loggedIn == false(基于控制台输出)时测试了此功能,并且应用程序崩溃基于在后续 viewController 上执行的代码。我知道它为什么会崩溃(没有用户数据),但我根本不知道为什么要执行 segue。

如果您需要更多代码来诊断,请询问。

最佳答案

在您的 Storyboard中,您需要在两个 View Controller 之间创建 segue,而不是到 DestinationViewController 的按钮。

请删除该转场并创建一个从您的 LoginViewController 到您的 DestinationViewController 的转场。

关于ios - 为什么要执行我的 segue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39103892/

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