Prototype UITableViewCell accessory covers up subviews

206 views Asked by At

I would like to use the provided disclosure indicator accessory in my prototype cell. However, enabling it covers up the right hand portion of my custom cell divider. (Since my divider does not span the full width of the cell, I do not want to use the built in divider).

Is there a way I can use the built in cell accessories, while still utilizing the full width of my cell's view?

1

There are 1 answers

1
HalR On

One thing that you can do is resize your divider, based on the location of the accessory view.

You can override layoutSubviews, like this:

- (void)layoutSubviews
{
    [super layoutSubviews];

    CGRect accessoryFrame = self.accessoryView.frame;
    CGRect yourCustomViewFrame = yourCustomView.frame;
    yourCustomViewFrame.size.width = accessoryFrame.origin.x - yourCustomViewFrame.origin.x;
    [yourCustomView setFrame:yourCustomViewFrame];
}