[英]UITableView displays separator at wrong position in iOS8 for some cells
We have a UITableView and it was working fine for iOS7 but when I tried in the iOS8 simulator, I saw the cell separator was placed incorrectly for most cells. 我们有一个UITableView,它适用于iOS7但是当我在iOS8模拟器中尝试时,我看到大多数单元格的单元分隔符放置不正确。 Strangely, some cells display the separator correctly.
奇怪的是,一些单元格正确显示了分隔符。
See the attached image: 见附图:
I set the cell height this way: 我这样设置单元格高度:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 70.0f;
}
Do you know what's happening? 你知道发生了什么吗? Thanks!
谢谢!
EDIT: 编辑:
A workaround I'm using in the meantime is to disable the separator... 我在此期间使用的解决方法是禁用分隔符...
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
...and paint it myself in the cell view... ...并在单元格视图中自己绘制......
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];
...but I'd like not to do it. ......但我不想这样做。
I had the same problem and here is how I solved it: 我有同样的问题,这是我如何解决它:
If you are using a custom cell for your table view and you have overridden layoutSubviews, you need to call it's superview's method at the beginning of the method: 如果您正在为表视图使用自定义单元格并且已覆盖layoutSubviews,则需要在方法开头调用它的superview方法:
- (void)layoutSubviews
{
[super layoutSubviews];
// Your implementation
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.