Struggling to move users between View Controllers

Once a user logs into my application, the below function should automatically redirect the user to a View Controller named ‘TabViewController’.

transitionToHome() {

let tabViewController = storyboard?.instantiateViewController(withIdentifier: Constants.Storyboard.TabViewController) as? TabViewController

view.window?.rootViewController = tabViewController
view.window?.makeKeyAndVisible()

}

Currently, when this function is run, it just produces a fully black screen, instead of taking the user to the TabViewController.

Here is a screenshot from Xcode of my ViewController.

Once a user logs into my application, the below function should automatically redirect the user to a View Controller named ‘TabViewController’.

transitionToHome() {
    
    let tabViewController = storyboard?.instantiateViewController(withIdentifier: Constants.Storyboard.TabViewController) as? TabViewController
    
    view.window?.rootViewController = tabViewController
    view.window?.makeKeyAndVisible()
    
}

Currently, when this function is run, it just produces a fully black screen, instead of taking the user to the TabViewController.

Here is a screenshot from Xcode of my ViewController.

Xcode picture

This is the code in my ‘TabViewController.swift’ file

import UIKit

class TabViewController: UIViewController {

 override func viewDidLoad() {
    super.viewDidLoad()
  }

  }

Any help would be greatly appreciated in explaining why this might be happening and how to actually get it to redirect to the TabViewController, thanks!

At what point are you calling transitionToHome()

PS, I also answered something similar on the fb page where you asked the same question

1 Like