相关疑难解决方法(0)

如何以分组样式设置UITableView中单元格的宽度

我已经为此工作了大约2天,所以我想我和你分享我的经验.

问题是:是否可以使分组的UITableView中的单元格宽度更小?

答案是不.

但是有两种方法可以解决这个问题.

解决方案#1:更薄的表 可以更改tableView的框架,以便表格更小.这将导致UITableView以减小的宽度渲染内部单元格.

对此的解决方案可能如下所示:

-(void)viewWillAppear:(BOOL)animated
{
    CGFloat tableBorderLeft = 20;
    CGFloat tableBorderRight = 20;

    CGRect tableRect = self.view.frame;
    tableRect.origin.x += tableBorderLeft; // make the table begin a few pixels right from its origin
    tableRect.size.width -= tableBorderLeft + tableBorderRight; // reduce the width of the table
    tableView.frame = tableRect;
}
Run Code Online (Sandbox Code Playgroud)

解决方案#2:让图像呈现细胞

此解决方案在此处描述:http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html

我希望这些信息对您有所帮助.我花了大约2天时间尝试了很多可能性.这就是剩下的.

iphone width uitableview ios

107
推荐指数
4
解决办法
9万
查看次数

标签 统计

ios ×1

iphone ×1

uitableview ×1

width ×1