Can't connect IBOutlet in Interface Builder

Viewed 38093

I'm having a weird experience. I create any type of iPhone application, add a UIViewController with Xib file. I can edit the xib file with controls and see them rendered if I run. Now i'm trying to add a few IBOutlets to the controller, so I add them to the .h file, synthesize on the .m file. Then i head over to Interface Builder to connect the outlets. I drag the UILabel to the UIView, and then i try to connect the File Owner (which my custom UIViewController), but all that i can select when i try to connect to the UILabel is "view", which is obviosly wrong. So I'm not able to connect IBOutlets to their controls in Interface Builder.

Any ideas?

19 Answers

I did a combination of the things in this thread and I finally had success.

In Interface builder (not xcode)

  1. File->Reload All Class Files
  2. File->Read Class Files (select MyClass.h)
  3. Reconnect File's Owner by
    a. Setting the Class to "MyClass"
    b. Reconnecting the View to the File's Owner's View

Everything is back to normal now. Weird.

Hope this helps more than it confuses ;-)

In Interface Builder File->Read Class Files, and point it to your File's Owner's class. That fixed it for me.

If you failed to connect your UI controls to code via Right-click (or CTRL) -> dropped down list, there is another way. In interface builder, press & hold CTRL, drug mouse from "File's Owner" in the Main window of Interface Builder to your UI control (label, button, etc). The dpopdown list with all defined by you Outlets will be appered. Just choice needed one!

I had the same problem, and I just tried diatrevolo's suggestion: Click File, then Read Class Files, and point to your File's s Owner class.

This fixed it for me. I would +1 diatrevolo, but I don't have any reputation yet...

I'm a total newbie at this, and I had the same problem. I went to try diatrevolo's suggestion, and, in doing so, found out what was causing my problem. I had originally created my ViewController somewhere random in the project hierarchy, and then moved them into the classes folder. This meant that the actual files were not in the classes folder, but the project thought that they were, so IB was looking in the wrong place. I moved the actual files in to the actual classes file with Finder, and then deleted and readded them in the project. Then everything worked!

Related