Last active
April 14, 2020 18:34
-
-
Save shawnbierman/0e8a32d7d2318ff93653b5d8baf98608 to your computer and use it in GitHub Desktop.
How to remove the LoginViewController.swift and replace with a UITabBarController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoginViewController: UIViewController { | |
// lots of code removed. | |
@objc func buttonAction() { | |
let windowScene = view.window?.windowScene | |
let sceneDelegate = windowScene?.delegate as! SceneDelegate | |
sceneDelegate.loadTabBarController(). | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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