【发布时间】:2020-11-08 10:42:30
【问题描述】:
我有一个 TestViewController.swift 和一个 TestViewController.xib 来展示 TestViewController 的布局。
要加载这个视图控制器,我有 this method:
let vc = TestViewController(nibName: "TestViewController", bundle: nil)
self.navigationController?.pushViewController(vc, animated: true)
一切正常,但如果我调用空初始化器:
let vc = TestViewController()
self.navigationController?.pushViewController(vc, animated: true)
或者使用 nil nibname
let vc = TestViewController(nibName: nil, bundle: nil)
self.navigationController?.pushViewController(vc, animated: true)
应用程序也可以继续工作而无需更改。明确指定 xib 文件的名称有什么意义?在这种情况下,三个调用有什么区别?
【问题讨论】:
标签: ios swift uiviewcontroller uinavigationcontroller xib