Skip to content

UIStoryboard Cells #3

@holtwick

Description

@holtwick

Hi, looks like your awesome toolkit does not work out of the box with UIStoryboard created cells (and I doubt it will work with NIBs anyway because of missing awakeFromNIB). Therefore I wrote a little workaround that seems to fix the problem:

- (void)configureCell {
    if(_configured) {
        return;
    }
    _configured = YES;

    [self.contentView addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionOld context:nil];


    PrettyTableViewCellBackground *bg = [[PrettyTableViewCellBackground alloc] initWithFrame:self.frame 
                                                                                    behavior:CellBackgroundBehaviorNormal];
    bg.cell = self;
    self.backgroundView = bg;
    [bg release];

    bg = [[PrettyTableViewCellBackground alloc] initWithFrame:self.frame
                                                     behavior:CellBackgroundBehaviorSelected];
    bg.cell = self;
    self.selectedBackgroundView = bg;
    [bg release];

    [self initializeVars];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self configureCell];        
    }
    return self;
}

I added the call here too:

- (void) prepareForTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath 
{
    [self configureCell];
    _tableViewStyle = tableView.style;
    self.position = [PrettyTableViewCell positionForTableView:tableView indexPath:indexPath];
}

Hope this is somehow usefull.

Cheers,
Dirk

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions