繁体   English   中英

成功验证后如何导航至视图控制器?

[英]How to navigate to view controller after successful verification?

我正在使用Digits-通过Twitter API进行电话号码验证,这是一个快速场景:用户点击Sign Up按钮, ex: LoginViewController > Digits API初始化以验证其电话号码->成功验证后,应用程序应移至下一个View Controller ex: HomeViewController但是会发生在成功验证用户身份后,该应用程序返回到以前的LoginViewController 这是我的代码:

LoginViewController

// MARK: - Sign Up Button
@IBAction func signUpPressed(_ sender: Any) {

    let configuration = DGTAuthenticationConfiguration(accountFields: .defaultOptionMask)

    configuration?.appearance = DGTAppearance()
    configuration?.appearance.backgroundColor = UIColor.white
    configuration?.appearance.accentColor = UIColor.red

    // Start the Digits authentication flow with the custom appearance.
    Digits.sharedInstance().authenticate(with: nil, configuration:configuration!) { (session, error) in
        if session != nil {

            //Print Data
            print(session?.phoneNumber!)
            print(session?.userID!)

            // Navigate to the main app screen to select a theme.
            self.performSegue(withIdentifier: "toSignUpVC", sender: self)

        } else {
            print("Error")
        }
    }

}

故事板的示例:

故事板

注意:在应用返回到LoginViewController之后,我可以再次点击SignUp按钮后成功进入SignUpViewController,因为Digits是第一次注册该设备,所以为什么Digits不移至下一个View Controller而不是返回到LoginViewController ,任何用户都不会知道他是否成功注册!

您可以通过添加以下代码来解决问题。 函数执行后应调用闭包。

   let deadline = DispatchTime.now() + .seconds(1)
   DispatchQueue.main.asyncAfter(deadline: deadline)  
   {
    self.performSegue(withIdentifier: "toSignUpVC", sender: self)
   }

暂无
暂无

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

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