I wish to load first view controller programatically and cargo second view controller subsequent robotically from first. I take advantage of this code:
SceneDelegate:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, choices connectionOptions: UIScene.ConnectionOptions) {
if let windowScene = (scene as? UIWindowScene) {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = SLLoadingViewController()
self.window = window
window.makeKeyAndVisible()
}
}
SLLoadingViewController:
override func viewDidLoad() {
tremendous.viewDidLoad()
load()
}
func load() {
let nav = SLNavigationViewController()
let mainView = StoreViewController()
nav.navigationBar.body.measurement = nav.navigationBar.sizeThatFits(CGSize(width: nav.navigationBar.body.measurement.width, peak: 2))
nav.viewControllers = [mainView]
current(nav, animated: false, completion: nil)
}
However this does not work. Final controller not displaying on display screen. If I take advantage of subsequent code all works effective:
override func viewDidLoad() {
tremendous.viewDidLoad()
button.body = CGRect(x: 100, y: 200, width: 30, peak: 20)
button.backgroundColor = .inexperienced
view.addSubview(button)
button.addTarget(self, motion: #selector(self.load), for: .touchUpInside)
}
@objc func load() {
let nav = SLNavigationViewController()
let mainView = StoreViewController()
nav.navigationBar.body.measurement = nav.navigationBar.sizeThatFits(CGSize(width: nav.navigationBar.body.measurement.width, peak: 2))
nav.viewControllers = [mainView]
current(nav, animated: false, completion: nil)
}
However On this case I take advantage of a button. Learn how to load final view controller from first with out button faucet?