我试图做一个带有操作的注册按钮,当按钮点击一个名为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吗? –