I'm trying to use a custom subclass of UITableViewCell
with the style set to UITableViewCellStyleSubtitle
and use it with registerClass:forCellReuseIdentifier:
. However, I'm not sure how to do this.
My thinking was to override the init
method and call
self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:myReuseIdentifier];
within it. However, I can't figure out which init
method gets called (or if this is even the right way to do this.)
I've tried to intercept all of the following init methods, but none of them seem to be the correct one when dequeueing a cell:
init
initWithCoder
initWithFrame
I've confirmed that dequeueReusableCellWithIdentifier:forIndexPath:
is returning a cell of the correct type so I know it's being created. I just don't know which init
method is being called so I can't set the default style.
I believe it calls initWithStyle:reuseIdentifier: for the table cell init.
From the apple docs
dequeueReusableCellWithIdentifier:
If you registered a class for the specified identifier and a new cell must be created, this method initializes the cell by calling its initWithStyle:reuseIdentifier: method. For nib-based cells, this method loads the cell object from the provided nib file. If an existing cell was available for reuse, this method calls the cell’s prepareForReuse method instead.
J
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