Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

You first need to create a class DetailedCell and add IBOutlets to that class.

Then in the Storyboard/IB, assign that class to the prototype cell and those outlets will be available to fill.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top