簡體   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