【发布时间】:2014-12-10 16:25:22
【问题描述】:
我关注了这个帖子:How to customize tableView separator in iPhone
问题是当我为我的单元格设置自定义高度时它无法正常工作。
我将向您展示两张图片,一张有两行的图片是为我的单元格设置自定义高度的结果。
自定义高度:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, cell.contentView.frame.size.height - 1.0, cell.contentView.frame.size.width, 1)];
lineView.backgroundColor = [UIColor darkGrayColor];
[cell.contentView addSubview:lineView];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 50;
}
【问题讨论】:
-
自定义高度是只针对一个单元格还是所有单元格?
-
您有自定义单元格吗?在一个笔尖?问题是在设置 lineView 后单元格会展开。如果你想让它粘在底部,你可以查看 autoresizingMask 或者设置 autoLayout 约束
标签: ios iphone uitableview