azamsharp
azamsharp

Reputation: 20076

Creating Custom UITableViewCell for reuse

I am creating custom UITableViewCell for customers and products. The cell design is exactly the same since it consists of one image and few labels. What is the best practice to do in these scenarios. At this point I have different cell classes for customers and products. Also, I create the cell directly into the storyboard so it cannot be reused.

Upvotes: 0

Views: 163

Answers (1)

jrturton
jrturton

Reputation: 119242

Rather than use prototypes in the storyboard, which can't be reused between view controllers, you can lay out your cell in a separate xib file (with a UITableViewCell or subclass as the top level object) and then register this with your table view for reuse as described here.

You can then use the same cell in multiple places. A new cell will be built from the nib, or dequeued for you, when you dequeue... in the cell for row method.

Upvotes: 1

Related Questions