我希望这个问题不重复,因为我找不到任何类似的东西。
我有两个视图控制器:
return [element.to_dict(show=['price']) for element in result_list]
NEWPhoneAuthViewController代码:
NEWPhoneAuthViewController
NEWVerifyCodeViewController
我的NEWVerifyCodeViewController代码是:
import UIKit
import Firebase
class NEWPhoneAuthViewController: UIViewController {
@IBOutlet weak var phoneTxtField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func submitPressed(_ sender: Any) {
let phoneNumber = phoneTxtField.text!
PhoneAuthProvider.provider().verifyPhoneNumber(phoneNumber, uiDelegate: nil, completion: { (verificationID, error) in
if let error = error {
debugPrint(error.localizedDescription)
return
}
guard let verificationID = verificationID else { return }
print("Verification ID")
print(verificationID)
let verifyScene = NEWVerifyCodeViewController()
verifyScene.verificationID = verificationID
self.performSegue(withIdentifier: "toCodefromPhoneAuth", sender: nil)
//self.navigationController?.pushViewController(verifyScene, animated: true)
})
}
}
现在问题是:当我点击NEWVerifyCodeViewController中的验证按钮时,应用程序崩溃,
注意:
所以我不确定为什么会发生这种情况,我的控制台在点击后没有显示任何错误,除了这些:
答案 0 :(得分:0)
所以我做了一个小调整,让我的项目有效。
我在NEWPhoneAuthViewController
中更改了此部分:
let verifyScene = NEWVerifyCodeViewController()
verifyScene.verificationID = verificationID
到:
首先创建了一个名为gVerificationID
的全局变量,并将其设置为:
gVerificationID = verificationID
多数民众赞成,不确定这是不是最好的做法,也不确定为什么第一个代码没有用,但这就是我修复它的方法。