custom uitableviewcells in storyboard
Asked Answered
R

1

15

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?

Rhnegative answered 29/12, 2011 at 1:29 Comment(0)
A
15

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.

Autolithography answered 29/12, 2011 at 2:16 Comment(2)
Also if that still doesn't work, go onto the cell in the storyboard and where it says Identifier type Cell or whatever your using in you table view controllerExercitation
And if THAT doesn't work, use the Connections Inspector from the right-most pane to connect the outlet to the UI widget. You'll still have to hand-code the IBOutlets in your @interface. Don't know why XCode won't see it and let you control-drag to the code...Omophagia

© 2022 - 2024 — McMap. All rights reserved.