Mac 10.14.5
Xcode 10.2.1
Swift 4.2
Storyboard上にあるViewControllerをプログラムから呼び出し方法
サンプルはMain.storyboardを対象としているので、あらかじめ設定の
「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
}
}