![](/img/trans.png)
[英]How to navigate to another view controller in the same tab of the tab bar controller in swift 3?
[英]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.