Get Nibname/What到底是不是nib?
Get Nib name/What exactly is a nib?
我正在尝试使用来自
this pre-built page menu pod from github
在说明中,它说:
var controller : UIViewController = UIViewController(nibName:"controllerNibName", bundle: nil)
controller.title = "SAMPLE TITLE"
controllerArray.append(controller)
这是我的代码:
var chatAreaCtrl : UIViewController = ChatAreaCtrl(nibName: "ChatAreaCtrl", bundle: nil)
chatAreaCtrl.title = "Chats"
controllerArray.append(chatAreaCtrl)
这是我的错误:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: ...(loaded)' with name 'ChatAreaCtrl''
我是编程新手,Swift 但我想我没有正确指定 Nib 是什么?
谢谢!
Nibfiles 是用户界面文件的旧名称。它们现在实际上是 .xib 文件(文件扩展名在前一段时间发生了变化。)但是老派开发人员和方法仍然使用术语 nib。
仍然支持 Nib 文件(或 XIB 文件,如果您愿意),但大多数人改用故事板。
如果您在 Xcode 中创建一个用户界面文件并以名称 ChatAreaCtl.xib
保存它,那么您将能够使用您显示的代码对其进行初始化。
与情节提要等效的是在情节提要中创建一个新场景来定义视图控制器的界面,然后使用 instantiateViewControllerWithIdentifier
创建该视图控制器的实例(instantiateViewControllerWithIdentifier
是相当于 initWithNibName:bundle:
的情节提要。或者我想我应该说 UIViewController(_nibName:bundle:)
代表 Swift。仍在使用 Swift 中函数模板的语法。)
我正在尝试使用来自 this pre-built page menu pod from github
在说明中,它说:
var controller : UIViewController = UIViewController(nibName:"controllerNibName", bundle: nil)
controller.title = "SAMPLE TITLE"
controllerArray.append(controller)
这是我的代码:
var chatAreaCtrl : UIViewController = ChatAreaCtrl(nibName: "ChatAreaCtrl", bundle: nil)
chatAreaCtrl.title = "Chats"
controllerArray.append(chatAreaCtrl)
这是我的错误:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: ...(loaded)' with name 'ChatAreaCtrl''
我是编程新手,Swift 但我想我没有正确指定 Nib 是什么?
谢谢!
Nibfiles 是用户界面文件的旧名称。它们现在实际上是 .xib 文件(文件扩展名在前一段时间发生了变化。)但是老派开发人员和方法仍然使用术语 nib。
仍然支持 Nib 文件(或 XIB 文件,如果您愿意),但大多数人改用故事板。
如果您在 Xcode 中创建一个用户界面文件并以名称 ChatAreaCtl.xib
保存它,那么您将能够使用您显示的代码对其进行初始化。
与情节提要等效的是在情节提要中创建一个新场景来定义视图控制器的界面,然后使用 instantiateViewControllerWithIdentifier
创建该视图控制器的实例(instantiateViewControllerWithIdentifier
是相当于 initWithNibName:bundle:
的情节提要。或者我想我应该说 UIViewController(_nibName:bundle:)
代表 Swift。仍在使用 Swift 中函数模板的语法。)