title: Viewcontroller just shows black screen after implementing a rootviewcontroller
body: <p>I am pretty new to programming, thats why I can't really figure out how to solve this issue. 
  I have implemented a rootviewcotnroller in the app delegate so that if the user is logged in he is pushed directly to the app content instead of the login view controller. 
  However it doesn't really work. As is already said I added the following code to the app delegate: </p>
  
  <pre><code>    window = UIWindow(frame: UIScreen.main.bounds)
      window?.makeKeyAndVisible()
      window?.rootViewController = MainViewController()
  </code></pre>
  
  <p>The MainViewcontroller is set up like this: </p>
  
  <pre><code>class MainViewController: UINavigationController {
  
  override func viewDidLoad() {
      super.viewDidLoad()
      if isLoggedIn() {
          let homeController = UserViewController()
          viewControllers = [homeController]
  
      }else {
  
          perform(#selector(showLoginController), with: nil, afterDelay: 0.01)
      }
  }
  
  fileprivate func isLoggedIn() -&gt; Bool {
      return UserDefaults.standard.isLoggedIn()
  }
  
  func showLoginController() {
      let loginController = LoginViewController()
      present(loginController, animated: true, completion: {
  
      })
   }
  }
  </code></pre>
  
  <p>To the Userviewcontroller I have added the following lines: </p>
  
  <pre><code> func handleSignout() {
  
      UserDefaults.standard.setisLoggedIn(value: false)
      print("is logged out")
  
  }
  
  @IBAction func SignOut(_ sender: Any) {
  
      handleSignout()
      if FIRAuth.auth()!.currentUser != nil {
  
          do {
          try? FIRAuth.auth()?.signOut()
  
              if FIRAuth.auth()?.currentUser == nil {
                  let loginViewViewcontroller = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Login") as! LoginViewController
                  self.present(loginViewViewcontroller, animated: true, completion: nil)
              }
          }   
      }
  }
  </code></pre>
  
  <p>Then I have created an extension with the UserDefaults to save the boolean Value whether the user is logged in or logged out: </p>
  
  <pre><code>extension UserDefaults {
  
  enum UserDefaultKeys: String {
      case isLoggedIn
  }
  
  func setisLoggedIn(value: Bool) {
      set(false, forKey: UserDefaultKeys.isLoggedIn.rawValue)
      synchronize()   
  }
  
  func isLoggedIn() -&gt; Bool {
      return bool(forKey: UserDefaultKeys.isLoggedIn.rawValue)
  }
  </code></pre>
  
  <p>}</p>
  
  <p>In the LoginviewController, which just shows a black screen if shown at first sight, I have added : </p>
  
  <pre><code>  func finishLoggingIn() {
  
      let rootViewController = UIApplication.shared.keyWindow?.rootViewController
      guard let MainNavigationController = rootViewController as? MainViewController else {return}
      MainNavigationController.viewControllers = [UserViewController()]
      print("is logged in")
      UserDefaults.standard.setisLoggedIn(value: true)
  
      dismiss(animated: true, completion: nil)
  
  }
  </code></pre>
  
  <p>This function is called when user pushes the login button. </p>
  
  <p>The app recognizes if the user is logged or not, but it doesn't matter if the user is logged in or not, that first view controller which is presented shows a black screen, which is most likely the loginviewcontroller but if the user is logged in the userviewcontroller shows a black screen as well if is the first view controller to be presented.  ... </p>
  
  <p>Has anybody an idea why that is? </p>