“loaded nib but the view outlet was not set” exception

后端 未结 6 1984
别那么骄傲
别那么骄傲 2020-12-06 00:41

I am trying to use UINavigationController. I have two views which are being created programmatically. When a UIButton is pressed on the first v

相关标签:
6条回答
  • 2020-12-06 00:52

    If you have tried everything and you still get this error, try re-creating the class file from scratch but remember to select the "Also create XIB file" check box. This will auto link up a few items that are not linked when creating these files separately. After this is created, you can likely cut and paste everything onto the new XIB and it should work fine.

    0 讨论(0)
  • 2020-12-06 00:58

    Do This(You have no view in xib so add one and then do this):

    enter image description here

    0 讨论(0)
  • 2020-12-06 01:13

    follo following steps

    1) open your xib file then right click on files owner and drag to your first view

    enter image description here

    2) then bind that view with outlet of "view"

    enter image description here

    hope you will get it...

    0 讨论(0)
  • 2020-12-06 01:13
    • 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

    Thanks,

    0 讨论(0)
  • 2020-12-06 01:13

    Select File's owner of your .xib, open the Identity Inspector, make sure Custom Class is set to the same name as your controller's class name. If you create IB file and Controller separately(in separate steps), you might forget to check this.

    0 讨论(0)
  • 2020-12-06 01:14

    If you are not seeing the "view" outlet to select from on the "Connections inspector" (rightmost) tab, I found that I had to go back to a generic view controller (e.g., UICollectionViewController) for the File's Owner Custom Class instead of my subclass that I had entered previously. After closing and reopening Xcode, the view outlet appeared again so I connected it as described in sagarcool89's answer. I then set my File's Owner Custom Class back to my subclass and have finally moved past this error.

    0 讨论(0)
提交回复
热议问题