【发布时间】:2014-09-20 09:37:41
【问题描述】:
我们有一个 UITableView,它在 iOS7 上运行良好,但是当我在 iOS8 模拟器中尝试时,我发现大多数单元格的单元格分隔符放置不正确。奇怪的是,有些单元格正确显示了分隔符。
见附图:
我这样设置单元格高度:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 70.0f;
}
你知道发生了什么吗?谢谢!
编辑:
我在此期间使用的解决方法是禁用分隔符...
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
...在单元格视图中自己绘制...
UIView* separator = [[UIView alloc] initWithFrame:CGRectMake(20, cellHeight-1, frame.size.width - 40, 1)];
separator.layer.borderWidth = 1;
separator.layer.borderColor = [[UIColor grayColor] CGColor];
[self addSubview:separator];
...但我不想这样做。
【问题讨论】:
-
虽然这应该可以工作,但您可以尝试在 TableView 本身上设置 rowHeight 属性吗?
-
谢谢,但设置
rowHeight并没有改变任何东西... :( -
你在使用 AutoLayout 吗?
-
不,它是由代码构建的 UITableView。我想我可以从代码中启用 AutoLayout,但我没有。
-
感谢您的提问。我遇到了完全相同的问题,iOS 8 中的分隔符关闭位置,但它在 iOS 7 中很好。我正在使用与现在相同的解决方法。
标签: ios objective-c ios8