【发布时间】:2015-09-08 08:46:02
【问题描述】:
我已经搜索过,但我没有找到解决方案,我有一个带有 uitableviewcell 的 tableview。对于我需要应用此自定义分隔符的单元格:
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(90, self.contentView.frame.size.height, 80, 1)];
lineView.backgroundColor = [UIColor lightGrayColor];
[self.contentView addSubView:lineView];
并且分隔符显示正确,现在,我不知道为什么如果我快速上下滚动表格视图,分隔符会在某些单元格上消失。我尝试设置:
- (void)layoutSubviews
{
[super layoutSubviews];
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(90, self.contentView.frame.size.height, 80, 1)];
lineView.backgroundColor = [UIColor lightGrayColor];
[self.contentView addSubview:lineView];
}
有什么建议吗?谢谢
【问题讨论】:
-
你试过 UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(90, self.contentView.frame.size.height - 1, 80, 1)]; ?
-
不要在
layoutSubviews方法中添加任何子视图,在初始化时添加视图并将其框架设置在layoutSubviews中 -
@ArbenPnishi 谢谢我认为设置 self.contentView.frame.size.height - 1 解决了我的问题!没有考虑框架高度!
标签: ios objective-c uitableview custom-cell