Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storyboards: How to add outlets to a prototype UITableViewCell?

I have added prototype cell in one of the controllers that is part of the storyboard I'm designing. It has various labels, buttons, bells and whistles. But how do I know create outlets to that cell's elements? If I click the assistant in Xcode, it will show me the dummy source of my inherited UITableViewController and not of the "DetailsCell" which inherits from UITableViewCell and is specified in the custom class input field in IB.

I could of course use ViewWithTag() but I'd rather have something strong typed.

like image 309
Krumelur Avatar asked May 21 '12 19:05

Krumelur


1 Answers

With any object you can create with IB, you can assign it to a different class (one that you wrote). This is not different for cells. In the same way you can make IB instantiate MyFooView instead of UIView (MyFooView being derived from UIView), you can do the same for the cells.

Click your cell, click the 3rd icon on the shelf to the right. You will see a section called "Custom Class" and a text field called Class. Select the new class you've just created that is derived from UITableViewCell (let's call it MyCell). You can add IBOutlets to the MyCell class.

like image 87
Cthutu Avatar answered Oct 11 '22 11:10

Cthutu