2017-04-12 58 views
0

我使用位数 - 由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") 
     } 
    } 

} 

例子:

Storyboard

注:后的应用程序返回到LoginViewController我可以去SignUpViewController成功之后我再次点击SignUp按钮,因为Digit在第一次注册设备时,为什么数字不会移动到下一个视图控制器,而不是返回到LoginViewController,任何用户都不会知道他是否成功注册了!

回答

0

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

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