loaded some nib but the view outlet was not set

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>

Loaded some NIB but the view outlet was not set

this problem is encountered when using the initwithnibname function and the view attribute of viewcontroller generated by NIB file

//load loc.xib

UIViewController * UIVC = [[UIViewController alloc] initWithNibName:@”loc” bundle:nil ];

[self.view addS ubview:UIVC.view ];

[UIVC release];

NibName[2203:207] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘-[UIViewController _ loadViewFromNibN amed:bundle :] loaded the “LOC” NIB but the view outlet was not set. ‘

the surface meaning is that we load the nib file, and the “view” attribute value has not been set.

the actual situation here is not that the view attribute value of the generated VC is nil, but that the generated VC has no view attribute. We use the VC defined by uiviewcontroller. Why does VC (view controller) have no view attribute

The solution:

1. Click the Xib file we want to load

2. On the right, select file’s owner

3. In the “custom class” attribute setting of tab of file’s owner, change the value of class to corresponding VC, Change it to uiviewcontroller,

4. At this time, in the tab of file’s owner, the view attribute of “settings to be connected” will appear, that is, the view in the view outlet was not set told by our compiler. When the class of file’s owner is nsobject, there is no view attribute

connect view attribute,

5. Win + R, OK

Similar Posts: