I have a custom UITableViewCell
that I use like this:
AppTableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"AppTableCell" owner:self options:nil];
for(id currentObject in topLevelObjects) {
if([currentObject isKindOfClass:[AppTableCell class]]) {
cell = (AppTableCell *)currentObject;
break;
}
}
}
Works flawlessly. But, I would like to do some custom things to the cell when they get created. Normally I would override something like initWithFrame
, but its not being used here. What method should I override to customize initialization?
The right way is to override awakeFromNib for UITableViewCell.
- (void)awakeFromNib
{
[super awakeFromNib];
// Do something
}
See references for more details.
Objects that are unarchived from a nib are sent the -initWithCoder:
message. That's your override point.
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