Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loaded nib but the 'view' outlet was not set

I added a new nib file to my project, and tried to load it.

However, when I click on the toolbar icon that is supposed to take me to the view that I created, I get an NSInternalInconsistencyException with the message:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "..." nib but the view outlet was not set.'

So I opened up my nib file, and I see for the view that there are no referencing outlets set. However, I try to click and drag the circle for "new referencing outlet" to File's Owner, but it won't let me...what do I need to do to get my view to display?

like image 404
John Avatar asked Jan 21 '11 20:01

John


4 Answers

This is Josh Justice proposal, but in a graphical way (pictures are mine):

  1. Select File owner
  2. On right hand side panel select custom class.
  3. Enter the custom class name

enter image description here

  1. On right hand side panel select oultets
  2. Drag view outlet to view component

enter image description here

Finally the View Controller is instantiated with the rolling code:

        PTFilterUserVC *aFilterUserVC = [[PTFilterUserVC alloc] initWithNibName:@"FilterVC" bundle:nil];

        //OPTIONAL.This is how 'I' am interested in present the view controller.
        [self.navigationController pushViewController:aFilterUserVC animated:YES];
like image 34
Javier Calatrava Llavería Avatar answered Oct 28 '22 16:10

Javier Calatrava Llavería


Here's what worked for me:

  • Open the XIB file causing problems
  • Click on file's owner icon on the left bar (top one, looks like a yellow outlined box)
  • If you don't see the right-hand sidebar, click on the third icon above "view" in your toolbar. This will show the right-hand sidebar
  • In the right-hand sidebar, click on the fourth tab--the one that looks a bit like a newspaper
  • Under "Custom Class" at the top, make sure Class is the name of the ViewController that should correspond to this view. If not, enter it
  • In the right-hand sidebar, click on the last tab--the one that looks like a circle with an arrow in it
  • You should see "outlets" with "view" under it. Drag the circle next to it over to the "view" icon on the left bar (bottom one, looks like a white square with a thick gray outline
  • Save the xib and re-run
like image 158
Josh Justice Avatar answered Oct 28 '22 16:10

Josh Justice


I can generally fix it by remaking the connection between File's Owner and the view. Control-drag from the File's owner to your View (in IB) and select view from the pop-up menu.

like image 77
Rohit Mandiwal Avatar answered Oct 28 '22 16:10

Rohit Mandiwal


The View Identity - Class Identity was not set. After setting it to the appropriate class, the issue was resolved.

like image 64
John Avatar answered Oct 28 '22 18:10

John