Xcode 4: Creating a UIView xib, not properly connecting

Viewed 33017

I'm trying to create a nib that contains a view that will be embedded in a TableViewCell. I've created the interface and implementation files, ResultCell.h and ResultCell.m. They're stock, out-of-the-box, no code changes.

I then create an empty XIB file, and drag a UIView onto it. Then I click File's Owner, and set the type to ResultCell. I click the view, and set its class to also be ResultCell.

Here are the problems I have:

  1. When using the Assistant Editor view (which I live in), the ResultCell.h file doesn't appear when I'm viewing the ResultCell.xib file. I have to force it to load by clicking on Automatic and selecting the file.
  2. When I drop a label in the view, and then Ctrl+Click and drag to the .h to create an outlet, I get this error message: "Could not insert new outlet connection: Could not find any information about the class named ResultCell."

I've tried creating and re-creating the view, and it's just not working, and I've started to lose my patience. Any help would be very, very appreciated!

33 Answers

I had the very same issue. And I tried :

  • Restarting Xcode
  • Deleting Derived Data
  • And many more

None of that worked. What worked for me was simply to :

  • Remove 'suspect' class files from Project (just remove References, huh?)
  • Re-add them to the project

And done!

When I try to auto generate the action function with below way I came this issue.

enter image description here

But I can done it with below, manual write the action function first, then drag on the region of the @IBAction funciton

I Just ran into this today on Xcode 12.1.

I did the typical delete derived data, and even restarted my computer, but no luck.

In the end I was able to fix this by.

  1. Selecting the View Controller in IB
  2. Change the class name in the right hand panel under Custom Class > Class to a random class name
  3. Change the class name back to the correct class name.
Related