Get the name Nib / What is nib?

I'm trying to implement a segue page menu in my application using pod from this ready-made menu menu from github

The instructions say:

var controller : UIViewController = UIViewController(nibName:"controllerNibName", bundle: nil) controller.title = "SAMPLE TITLE" controllerArray.append(controller) 

This is my code:

  var chatAreaCtrl : UIViewController = ChatAreaCtrl(nibName: "ChatAreaCtrl", bundle: nil) chatAreaCtrl.title = "Chats" controllerArray.append(chatAreaCtrl) 

What causes my error:

  Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: ...(loaded)' with name 'ChatAreaCtrl'' 

I am new to programming and Swift, but I think I am not indicating that Nib is correct?

Thanks!

+5
source share
1 answer

Nibfiles is the old user interface file name. In fact, they are .xib files (the file extension changed a while ago). But older school developers and methods still use the term nib.

Nibfiles (or XIB files if you like) are still supported, but most people use storyboards.

If you create a user interface file in Xcode and save it with the name ChatAreaCtl.xib , you can initialize it using the code you show.

The equivalent of a storyboard is to create a new scene in your storyboard that defines the interface for your view controller, and then use instantiateViewControllerWithIdentifier to instantiate this view controller ( instantiateViewControllerWithIdentifier is a storyboard equivalent to initWithNibName:bundle: Or, I think I should say UIViewController(_nibName:bundle:) for Swift, still using syntax for function templates in Swift.)

+4
source

All Articles