gpt4 book ai didi

ios - Swift - 在 VC 中登录,允许任何人输入而不验证用户名和密码匹配或保存

转载 作者:行者123 更新时间:2023-11-28 15:12:50 26 4
gpt4 key购买 nike

同时使用 firebase。我的注册运作良好,它注册了用户。但是我的登录在开始时工作正常,但现在它允许任何人转到下一个 View (登录)。

这是我的代码:

登录VC..

import UIKit
import Firebase

class SignInVC: UIViewController {
@IBOutlet weak var emailTF: UITextField!
@IBOutlet weak var passwordTF: UITextField!

@IBAction func onSignInTapped(_ sender: Any) {
guard let email = emailTF.text,
email != "",
let password = passwordTF.text,
password != ""
else {
AlertController.showAlert(self, title: "Missing Information", message: "Please fill in username and password")
return
}

Auth.auth().signIn(withEmail: email, password: password) { (user, error) in
guard error == nil
else {
AlertController.showAlert(self, title: "Oops!", message: error!.localizedDescription)
return
}
guard let user = user else {return}
print(user.email ?? "Missing email address")
print(user.displayName ?? "Missing name")
print(user.uid)

self.performSegue(withIdentifier: "signInSegue", sender: nil)
}
}

//remove keyboard
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
self.view.endEditing(true)
}
}

AlerControllerVC

import UIKit
import Firebase

class AlertController {
static func showAlert(_ inViewController: UIViewController, title: String, message: String) {
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .default, handler: nil)
alert.addAction(action)
inViewController.present(alert, animated: true, completion: nil)
}
}

我试了很多次,然后又重写了一遍,但还是不能正常工作,执行时它说:

".SignInVC: 0x7fd99c208280> whose view is not in the window hierarchy!"

最佳答案

请检查您的转场是从按钮到 ViewController 还是从 ViewController 到 ViewController。如果它是从按钮到 VC 那么它不依赖于你写的代码

关于ios - Swift - 在 VC 中登录,允许任何人输入而不验证用户名和密码匹配或保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47357218/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com