Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic storyboard redirect on XCode 8 with SWIFT 3

Tags:

xcode8

swift3

Using SWIFT 3 on XCode 8, is there a way to redirect the app to your Custom Storyboard without renaming the field "Main storyboard file base name" on info.plist file?

like image 814
Marcelo Gracietti Avatar asked Dec 10 '25 02:12

Marcelo Gracietti


1 Answers

You can redirect your app to your custom storyboard via the AppDelegate, so you don't have to care about the "Main storyboard file base name" on info.plist file.

You need to get the instance of the initial View Controller of your custom storyboard and then call:

guard let window = UIApplication.shared.delegate?.window! else { return }
window.makeKeyAndVisible()
window.rootViewController = yourCustomViewControllerInstance

This can be called inside application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)

Hope it helps.

like image 130
Natan Avatar answered Dec 13 '25 18:12

Natan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!