In my tableview, I need a bunch (5-6 types) of different cells. All have the same visual layout for items, but content wise (label names, pictures and colors), they differ a lot.
So I have a CustomUITableViewCell base class, designed in Interface Builder with this common design. This CustomUITableViewCell class server as a base class for bunch of cell subclasses.
I generate these subclasses with a class method from a factory class using factory pattern.
These subclasses do not have xibs. Why would they, the have common design.
Now the problem is, for each subclass I need a different reuse identifier.So, one would think lets override the default initializer for each subclass, and in it, call another initializer, the initWithStyle:reuseIdentifier:
.
The problem is it requires the style to specify. I can't put nil
there, it complains. But I do not need any style from Apple, I have obviously my own style, why would I do the custom design if I wanted to have a stock style. I only need to specify the reuseIdentifier.
How to assign reuse identifier if it's readonly property and it seems that the only way to provide it is through the initializer?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…