heyred
heyred

Reputation: 2051

How to establish outlet connection in Xcode

I am following a tutorial HERE on creating a table-view controller in Xcode. I am using the latest version of Xcode (Xcode 5). At the top of the tutorial it says its for iOS 5.

In the tutorial a cell is created and an UIImage and a few labels are dragged onto the cell. It goes on to say to Ctrl-Click the white space of the cell and then drag to the labels and image to establish the outlet connection. See screen grab from tutorial.

enter image description here

When I do this, I dont get the same options as per the tutorial. The only options I get are shown below in this screen grab (note I chose to only add one label and leave out image for the purpose of my application).

enter image description here

Can anyone please let me know what Im doing wrong or how else I can create this connection? I have Googled it for the last hour and all I could see was how to create IBOutlets.

Alternatively, does anyone know of any tutorials similar to this one? This one suits my needs perfect as I will be creating a view similar to the second part of this tutorial. Like I mentioned Im working with Xcode 5.

Upvotes: 2

Views: 3556

Answers (3)

momodude22
momodude22

Reputation: 112

Although this might be a little late, I recently just stumbled upon this problem myself and figure out the answer. I used the same tutorial as you, and could not seem to generate the proper options when I did the control + drag.

Instead of dragging the labels to the whitespace of the custom cell, you will be dragging from the Connections tab of the custom cell. To do this:

First, make sure your labels are properly declared in CarTableViewCell.h and synthesize them in CarTableViewCell.m.

Second, change the custom class in the storyboard for the prototype cell from UITableViewCell to CarTableViewCell.

Next, click on the cell prototype in storyboard. Using Utilities, go to the connections tab (the last one with the arrow). If everything is linked properly in your header files, you should see "makeLabel", "modelLabel", and "carImage" under the Outlets section.

Finally, click the little circle next makeLabel and drag it over to the proper label in your custom cell. Do this for modelLabel as well as carImage, just using the associated outlet and label or imageView for each.

This solved my connection problem, and after following the rest of the tutorial, everything worked!

Upvotes: 3

Jacobanks
Jacobanks

Reputation: 127

Is your cell a custom cell. If not click on your cell and go to the attribute inspector then under table view cell choose the style as custom

Upvotes: 1

CoNgL3
CoNgL3

Reputation: 56

Is your TableViewCell connected to the "CarTableViewCell"?

Arrow to Cell

Click on the cell and make sure the custom class is set to CarTableViewCell.

And your .h file matches the one in the tutorial

#import <UIKit/UIKit.h>
@interface CarTableViewCell : UITableViewCell
@property (nonatomic, strong) IBOutlet UIImageView *carImage;
@property (nonatomic, strong) IBOutlet UILabel *makeLabel;
@property (nonatomic, strong) IBOutlet UILabel *modelLabel;
@end

Try again, and it should be like the tutorial.

-Cong

Upvotes: 1

Related Questions