为什么它是UIView而不是UIViewController的子类xib中的UIViewController?

问题描述:

当我新创建UIViewController的子视图以及xib文件时,我发现它是而不是xib文件中的UIViewController
那么为什么Xcode像这样实现xib文件呢?什么目的?为什么它是UIView而不是UIViewController的子类xib中的UIViewController?

新创建的类: -

enter image description here

的厦门国际银行文件: -

enter image description here

这是UIViewController型只需选择File'S Owner后检查identity inspector ,你会发现它已经设置了类NewViewController喜欢这个图片。

enter image description here

另外,请检查您的选择之后view该检查connection inspector,你看到它与File's Owner view这样的形象连接。

enter image description here

+0

我知道,使视图与''NewViewController's'连接self.view'。现在你了。 –

+1

你说得对。 Xcode链接了视图,文件所有者和NewVIewController类。但是这样,它总是会导致一些bug。所以每次我都会删除文件所有者的“身份检查器”中的视图和“NewViewController”名称,并且自己拖动一个新的UIViewController,并在UIViewController的“NewVIewController”中填写身份检查员。这很烦人。 –

+0

您不能在'XIB'内添加'UIViewController',您需要添加'UIView'并将其与FIle的所有者视图连接起来。 –