ログインボタンを押してホームビューコントローラに移動したときにナビゲーションバーが表示されず、私のストーリーボードをセットアップしてすべてをうまく入れましたが、この時点で固まっていると思いますコード。ナビゲーションが表示されないXcode 8.1 iOS 10 Swift 3
実際にはセグはありませんが、代わりにコーディングがあります。ナビゲーションの仕組みはどうですか?私はナビゲーション
let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home")
self.present(vc!, animated: true, completion: nil)
@IBAction func loginAction(_ sender: Any) {
if self.emailTextField.text == "" || self.passwordTextField.text == "" {
//Alert to tell the user that there was an error because they didn't fill anything in the textfields because they didn't fill anything in
let alertController = UIAlertController(title: "Error", message: "Please enter an email and password.", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
} else {
FIRAuth.auth()?.signIn(withEmail: self.emailTextField.text!, password: self.passwordTextField.text!) { (user, error) in
if error == nil {
//Print into the console if successfully logged in
print("You have successfully logged in")
//Go to the HomeViewController if the login is sucessful
let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home")
self.present(vc!, animated: true, completion: nil)
} else {
//Tells the user that there is an error and then gets firebase to tell them the error
let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
}
}
}
ナビゲーションコントローラにはナビゲーションバーを表示するオプションがあります。チェックされているかどうかを確認してください。 – Amanpreet
質問が更新され、ナビゲーションバーが有効になっていることを確認しました –
画像が表示される場合があります –