【发布时间】:2015-09-10 05:41:19
【问题描述】:
我有一个具有不同单元格高度的 UITableView。我还使用以下代码添加了一个自定义分隔线
UIView* separatorLineView = [[UIView alloc]initWithFrame:CGRectMake(1, cellReport.frame.size.height-1, table.frame.size.width-1, 1)];
separatorLineView.backgroundColor = [UIColor grayColor];
[cellReport.contentView addSubview:separatorLineView];
当我滚动表格时,行之间会出现额外的分隔符,我不明白为什么?我错过了什么吗?帮帮我。 简而言之,UITableView 在某些单元格的错误位置显示分隔符。已附上示例图像以供参考。
P.S:我没有使用自动布局
【问题讨论】:
-
试试这个框架:CGRectMake(cell.frame.origin.x,cell.frame.size.height-1,cell.frame.size.width,1)
-
@SaurabhPrajapati 实际上我只在我的代码中使用了它。它不起作用。我已经编辑了我的答案。请看一下
-
您使用的是自定义单元格吗?然后将 cell.contentView addSubview:separatorLineView 替换为 ** cellReport.contentView addSubview:separatorLineView** 可能有问题
标签: ios objective-c iphone uitableview