简体   繁体   English

为什么要执行我的检定?

[英]Why is my segue being performed?

In my iOS app, I have a log in Button to go from one viewController to another, which uses the following function: 在我的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"
    }
}

There's a function which runs within viewDidLoad() that updates the loggedIn value. viewDidLoad()中运行的函数可以更新loggedIn值。 I've tested this function when loggedIn == false (based on console output), and the app crashes based on code that executes on the subsequent viewController . 我在loggedIn == false时测试了此功能(基于控制台输出),并且该应用程序根据在随后的viewController上执行的代码崩溃。 I know why it crashes (no user data) but I don't know why the segue is being performed at all. 我知道为什么它崩溃(没有用户数据),但是我根本不知道为什么执行segue。

If you need more code to diagnose please ask. 如果您需要更多代码来诊断,请询问。

In your storyboard you need to create the segue between two view controllers instead of button to DestinationViewController. 在情节提要中,您需要在两个视图控制器之间创建序列,而不是在DestinationViewController中创建按钮。

Please remove that segue and create one segue from your LoginViewController to your DestinationViewController. 请删除该序列,并从LoginViewController到DestinationViewController创建一个序列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM