I made a new view controller in Storyboard and made a new .Swift file that inherits UIViewController
. However, my viewDidLoad()
is not being called.
What do I need to do to connect my view controller in my story board to my .swift code so viewDidLoad()
is called?
I see there's this: How to connect storyboard to viewcontroller
However, in a default project, FirstViewController(storyboard) doesn't have FirstViewController in that box, it is empty, yet viewDidLoad()
is still called. It doesn't make sense.
Open the storyboard and add a Container View to the View Controller where you want the SwiftUI View to appear. This Container View will then add an additional View Controller which is linked to the Container via an Embed Segue.
Embedding the SwiftUI view into your storyboard is super simple, just follow the three steps below: Step 1: Inside your storyboard file click on the + button and drag and drop a Hosting View Controller. This View Controller is capable of hosting a SwiftUI view.
Circuit
).Identity Inspector
on the rightCustom Class > Class > Type name of your swift file
.DONE :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With