Mac 10.14.5
Xcode 10.2.1
Swift 4.2
How to call a ViewController from Storyboard programmatically
This sample targets Main.storyboard. Make sure to clear the settings beforehand:
“General” > “Deployment Info” > “Main Interface”
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? //Main Window
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateInitialViewController()
window?.rootViewController = viewController
window?.makeKeyAndVisible()
return true
}
}
