How to reuse common subelements of a custom UITableViewCell with iOS Interface Builder?
I have several custom 开发者_如何学编程UITableViewCell
, which share a lot of common subelements.
I tried creating a UIView
and using it as a subview for all the table cells, but obviously this wouldn't work, since entities in IB are object instances, not classes or templates.
How can I capture these common subelements in a custom control and drag it into all table cells? Ideally it would be a solution where one doesn't have to muck around with programmatic Nib loading and whatnot.
I think the "easiest" answer would be to create your CustomSubview class with the common, shared elements programmatically, and then in IB add a UIView subview and give it the class of CustomSubview. You'll have to write the subview in code, but you will still be able to reuse it in your various xibs.
精彩评论