I occasionally find myself copy/pasting
custom cells between UITableViews
in my storyboard which is slowly becoming a maintenance nightmare (i.e., a simple change must now be made to each custom cell across several UITableViews
).
Is it possible to create one custom cell in a storyboard or xib
file and then reference it from multiple UITableViews
? I'm thinking there's got to be a way to specify a NIB
name for a static/prototype
cell similar to how you can specify a NIB
name for a UIViewController
when editing a normal xib
.
BTW... I know how to do this via code. What I'm looking for is a way to do this from within the storyboard editor itself.
I know of a way, but it does require a little code in a custom class. Make a subclass of UITableViewCell that loads itself from a nib. Then just set the class of your cells to this subclass. For a good method of having a view replace itself with a different version loaded from a nib see this blog post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With