开发者

How to reuse common subelements of a custom UITableViewCell with iOS Interface Builder?

开发者 https://www.devze.com 2023-01-19 15:04 出处:网络
I have several custom 开发者_如何学编程UITableViewCell, which share a lot of common subelements.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消