views:

730

answers:

4

I am having a peculiar problem with the iPhone SDK.

I have tried to run several tutorials from different sources on my development machine. The problem always seems to be in connecting the code to a view in Interface Builder. If I have a button or data field (or some other library function) and I declare some properties in the viewcontroller.h file, I launch Interface Builder by clicking on the .xib file and attempt to make a connection by dragging from the referencing outlet in the connection viewer and the only possible connection presented (present in the pop-up box is view). No other options are available regardless of what code is available. Has anybody experienced this or am I missing something obvious?

+4  A: 

In your controller's header file, make sure you are using IBOutlet on your controls and IBAction on your methods that you wish to link to link up in Interface Builder. Also, make sure that your controller class is defined as the "class" for the XIB in the Inspector window (a.k.a. File's Owner)

Marc Novakowski
A: 

Are you sure that Interface Builder is up to date on the class definition? Try File > Reload All Class Files to update it.

TALlama
A: 

Can you add controls to the interface with code and then link to them in code w/out ever having to use the IB?

A: 

Also make sure that the type of your property matches the type of the object you're connecting to. I just had this same problem, and it turned out that Interface Builder was refusing to connect my image view to the corresponding property because the property was a UIImage * and not a UIImageView *.

If you were just compiling a tutorial, perhaps your problem was something different, but it would have been easy to type in the wrong property class name, I suppose.

David Maymudes