【问题标题】:How to navigate to view controller after successful verification?验证成功后如何导航到视图控制器?
【发布时间】:2017-04-12 14:11:33
【问题描述】:

我正在使用 Digits - by Twitter API 进行电话号码验证,一个快速的场景:用户点击注册按钮ex: LoginViewController -> Digits API 初始化以验证他的电话号码 ->成功验证后,应用程序应该移动到下一个视图控制器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")
        }
    }

}

故事板示例:

注意: App返回LoginViewController后我再次点击SignUp Button后可以成功进入SignUpViewController,因为Digits是第一次注册设备,所以Digits为什么没有移动到下一个 View Controller 而不是回到 LoginViewController,任何用户都永远不会知道他是否成功注册!

【问题讨论】:

    标签: swift3 ios10 twitter-fabric twitter-digits google-fabric


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-06
      • 2023-03-17
      • 1970-01-01
      • 2013-04-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多