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?
The answer to problem for me was to make sure
xib
file name andswift
file name should not be same. As when creating object of class it was giving priority toxib
file and in that caseXIB
loading was failing to find View outlet.and I was trying to create object like
to to solve this issue I renamed my xib file to
data_fragment.xib
and voila everything worked charm.To anyone that is using an xib method to create a UIView and having this problem, you will notice that you won't have the "view" outlet under the connections inspector menu. But if you set the File's Owners custom class to a UIViewController and then you will see the "view" outlet, which you can just CMND connect an outlet to the CustomView.
The View Identity - Class Identity was not set. After setting it to the appropriate class, the issue was resolved.
Are you sure you have a UIView (or subclass) assigned to the "view" property of yourViewController?
Right click on "File Owner" in the left pane of the xib for yourViewController and verify that the "view" outlet is set. If not, set it to a view!
this will definetly fix the Issue
For me, the problem was caused by calling
initWithNibName:bundle:
. I am using table view cells from a nib file to define entry forms that sit ontableViews
. As I don't have a view, doesn't make sense to hook to one. Instead, if I call theinitWithStyle:
method instead, and from within there, I load the nib file, then things work as expected.I had the same problem, but a different solution was called for. The problem in this case was the class of the File Owner was not connected to xib file.