Custom UITableVIewCell initialization not called

initialization, ios, uitableview

Solution

If the cells come from a storyboard or nib file, then `initWithStyle:reuseIdentifier` is not called, `initWithCoder:` is called instead.

Here's a typical implementation of an overwritten `initWithCoder:`:

-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
       // Do your custom initialization here
    }
    return self;
}

Will not work if you need to access IBOutlet during custom initialization.

Problem

I have custom UiTablleviewCell with some images and labels, and I would like to have rotated label in tableview cell...so I would like to edit initWithStyle method, but it seems like it's never called. ``` - (id)initWithStyle:(UITableViewCellStyle)stylereuseIdentifier:(NSString*)reuseIdentifier{ NSLog(@"creating cell"); self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { } return self;} ``` but in my log, I cant see this message. In tableview I have standard cellForRow method ``` - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *simpleTableIdentifier = @"messagesCell"; TBCellMessagesCell *cell = (TBCellMessagesCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; cell.selectionStyle = UITableViewCellSelectionStyleNone; // smt stuff return cell; } ``` so I'm wondering how does tableview initialize tableviewcells, I can think about some workarounds but I would like to have it clean. Thank you.

Original source