2017-01-10 4 views
1

Навигационная панель не появляется после нажатия кнопки входа в систему, когда она переходит к контроллеру Home view, и я настроил свою раскадровку и положил все хорошо, но я думаю, что я застрял на этом этапе код.Навигация не отображается Xcode 8.1 iOS 10 Swift 3

На самом деле, нет никакого выделения, кроме кодирования, поэтому, как я делаю навигацию?

Code I используется для выполнения навигации

let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home") 
self.present(vc!, animated: true, completion: nil) 

Diagram of the application page flow

@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) 
      } 
     } 
    } 
} 
+0

Навигационный контроллер имеет возможность отображать навигационную панель. Убедитесь, что он установлен или нет. – Amanpreet

+0

Я обновил вопрос и включил навигационную панель –

+0

Вы можете увидеть изображение –

ответ

0

Заменить код:

let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home") 
self.present(vc!, animated: true, completion: nil) 

С помощью этого Кодекса:

let vc : YourViewController = self.storyboard?.instantiateViewController(withIdentifier: "Home")as! YorViewController 
let navController = UINavigationController(rootViewController: vc) 
self.present(navController, animated: true, completion: nil) 

Вы просто пытаетесь представить диспетчеру навигацию вид. Дайте ей навигацию программно, тогда она отобразит навигационную панель.

+1

Thankyousomuchhhhhhhhhh <3 –

+0

Ваше приветствие :) Пожалуйста, проголосуйте за ответ. – Amanpreet

+0

У меня нет репутации 15, поэтому я не могу голосовать :(Но я снова получу более 15+ репутации thanx :) –

0

Вы действительно используете navigationController? Если да, то должно ли оно быть pushViewController, а не present?

navigationController?.pushViewController(vc, animated: true)