views:

50

answers:

1

I want to change the width of the cell content. (see the pic) alt text

My code:

 CGSize contentViewSize = cell.contentView.bounds.size;
    contentViewSize.width = 20.0f;

But there is no effect, what's wrong?
Any suggestion will be appreciated, thanks.

+1  A: 

You need to re-assign the frame for the cell's contentView.

CGRect oldFrame = cell.contentView.frame;
cell.contentView.frame = CGRectMake( oldFrame.origin.x,
                                     oldFrame.origin.y, 
                                     oldFrame.size.width + 20, 
                                     oldFrame.size.height );
Jacob Relkin
It doesn't work. Actually I want to change the width of both textLabel and detailTextLabel, so I also tried set the width <code>"CGSize contentViewSize = cell.contentView.bounds.size; contentViewSize.width = 20.0f;"</code> . doesn't work, either...thanks though.