更改单元格内容的宽度

时间:2010-05-16 17:14:06

标签: iphone objective-c

我想更改单元格内容的宽度。 (见图) alt text http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/Art/tv_cell_parts.jpg

我的代码:

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

但是没有效果,有什么不对? 任何建议将不胜感激,谢谢。

1 个答案:

答案 0 :(得分:1)

您需要为单元格的frame重新分配contentView

CGRect oldFrame = cell.contentView.frame;
cell.contentView.frame = CGRectMake( oldFrame.origin.x,
                                     oldFrame.origin.y, 
                                     oldFrame.size.width + 20, 
                                     oldFrame.size.height );
相关问题