Skip to content

Instantly share code, notes, and snippets.

@shawnbierman
Last active April 14, 2020 18:34
Show Gist options
  • Save shawnbierman/0e8a32d7d2318ff93653b5d8baf98608 to your computer and use it in GitHub Desktop.
Save shawnbierman/0e8a32d7d2318ff93653b5d8baf98608 to your computer and use it in GitHub Desktop.
How to remove the LoginViewController.swift and replace with a UITabBarController
class LoginViewController: UIViewController {
// lots of code removed.
@objc func buttonAction() {
let windowScene = view.window?.windowScene
let sceneDelegate = windowScene?.delegate as! SceneDelegate
sceneDelegate.loadTabBarController().
}
}
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
window?.rootViewController = LoginViewController()
window?.makeKeyAndVisible()
}
func loadTabBarController() {
let tabBarController = UITabBarController()
let queueNC = UINavigationController(rootViewController: QueueViewController())
let messagesVC = UINavigationController(rootViewController: MessagesViewController())
tabBarController.viewControllers = [queueNC, messagesVC]
window?.rootViewController = tabBarController
window?.makeKeyAndVisible()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment