Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom uitableviewcells in storyboard

I think I got all the steps down but I must be missing something because I can't make a connection from the labels in the cell to the code.

Here's what I'm doing:

  1. set style of cell to custom
  2. dragging some labels onto the prototype cell.
  3. adding a new file to the project and making it a subclass of UITableViewCell
  4. in the identity inspector of the cell im trying to customize, I set its class to the new class I just created.
  5. TRY to control drag from the labels on the cell to the headerfile of the class I just created to setup an IBOutlet, but it won't let me.

What am I missing?

like image 311
ladookie Avatar asked Dec 29 '11 01:12

ladookie


People also ask

How do you create a table view cell subclass?

The same way that you create a UIViewController or UITableViewController : In your project, go to New File. Select Cocoa Touch Class under iOS. The subclass is UITableViewCell and the name is whatever name you're giving it. Within that class, you drag your buttons, labels, etc to create your outlets.


1 Answers

Declare the label as a property in the custom cell class. In the table view controller, alloc or dequeue the cell as your custom type, not as UITableViewCell. In the Xcode storyboard, control drag from the cell itself (for example, the far bottom right corner) to the label that is in the cell to connect the outlet.

like image 115
paul.lander Avatar answered Oct 10 '22 23:10

paul.lander