如何在Storyboard中将ViewController.swift连接到ViewController? [英] How to connect ViewController.swift to ViewController in Storyboard?
问题描述
我在Storyboard中制作了一个新的视图控制器,并制作了一个继承UIViewController
的新.Swift文件.但是,我的viewDidLoad()
没有被呼叫.
我需要怎么做才能将故事板上的视图控制器连接到.swift代码,以便调用viewDidLoad()
?
我看到是这样的:如何将情节提要与视图控制器连接 >
但是,在默认项目中,FirstViewController(storyboard)在该框中没有FirstViewController,它为空,但仍调用viewDidLoad()
.这没有道理.
- 在情节提要或场景列表中选择ViewController(我的称为
Circuit
). - 单击右侧的
Identity Inspector
- 选择
Custom Class > Class > Type name of your swift file
.
完成:)
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.
- Choose your ViewController in the storyboard or scene list (mine is called
Circuit
). - Click on the
Identity Inspector
on the right - Select
Custom Class > Class > Type name of your swift file
.
DONE :)
这篇关于如何在Storyboard中将ViewController.swift连接到ViewController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!