我試圖做一個帶有操作的註冊按鈕,當按鈕點擊一個名爲getVPhoneNumber的函數啓動時。並且在電話驗證成功後,它啓動一個名爲Digits by Fabric
的電話驗證API,電話驗證成功後,該電話號碼將包含電話號碼,並且SignUp btn中的result var
應該接收該號碼,以便它可以對另一個VC執行。回調後無法執行成功返回
的問題是它不performSegue,只是停留在
登錄視圖控制器:
func getVPhoneNumber(completion: @escaping (_ result: String)->()) {
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!)
//Assign Value to global var vPhoneNumber.
self.vPhoneNumber = session?.phoneNumber!
print("TESTING COMPLETION")
completion((session?.phoneNumber!)!)
} else {
print("Error")
}
}
}
//SignUp Button:
@IBAction func signUpPressed(_ sender: Any) {
getVPhoneNumber() { (result) ->() in
// do stuff with the result
print(result)
print("Going To SignUp VC")
self.navigateToMainAppScreen()
}
}
//NavigateToMainApScreen Function
fileprivate func navigateToMainAppScreen() {
performSegue(withIdentifier: "toSignUpVC", sender: nil)
}
故事板概述:
注:「在電話驗證過程完成之前,不會在控制檯中打印「正在註冊VC」 ed,那就是我想要的,但是因爲它通過打印該聲明來繼續這個過程,爲什麼它沒有啓動PerformSegue?爲什麼只打印聲明。
在此先感謝,如果我的某些解釋不明確,我很抱歉。
所以唯一的問題是segue沒有執行?其他一切按預期工作?我們能否看到您的'navigateToMainAppScreen'功能? :) –
是的,只有海牙沒有執行,其他一切按預期工作,我現在要添加'navigateToMainAppScreen'代碼:) –
你在主線程中調用performSegue嗎? –