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?


You guys are right, but as I'm a newcomer it took me a little while to figure out all the steps to do that. 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 third 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

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

  • Select File owner
  • On right hand side panel select custom class.
  • Enter the custom class name
  • 在这里输入图像描述

  • On right hand side panel select oultets
  • Drag view outlet to view component
  • 在这里输入图像描述

    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];
    

    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.

    链接地址: http://www.djcxy.com/p/24402.html

    上一篇: MacRuby和Interface Builder属性

    下一篇: 加载的笔尖,但'视图'出口没有设置