简体   繁体   English

UITableViewCell隐藏的内容在其他单元格上重叠

[英]UITableViewCell hidden content overlaps on other cells

I have a table,with settings that cell height is 40px. 我有一张桌子,其单元格高度为40px。 If my cells have a label, image or any other component starting at 41px it will still appear in the table overlaping the cells underneath. 如果我的单元格具有标签,图像或其他任何以41px开始的组件,它将仍然出现在表格中,与下面的单元格重叠。 How to resolve this? 如何解决呢? I do not want the rest of the cell to be shown, just the height that is set in my table settings. 我不希望显示单元格的其余部分,而只显示表格设置中设置的高度。

Thank you. 谢谢。

Please add up these methods and try, 请加总这些方法并尝试,

-(float)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 1)] autorelease];
    view.backgroundColor = [UIColor clearColor];
    return view;
}

Using this will be considered as end of data from data source. 使用此功能将被视为来自数据源的数据结束。 And rest cells will not be displayed. 其余单元格将不会显示。

[Will solve this issue - If my cells have a label, image or any other component starting at 41px it will still appear in the table overlaping the cells underneath ] [将解决此问题- 如果我的单元格具有以41px开始的标签,图像或任何其他组件,它将仍然出现在表格中,与下面的单元格重叠 ]

You want to hide the content of cell that is below the 40px level? 您要隐藏低于40px的单元格内容吗? Add UIView to cell.contentView with white colour above the content of cell with 41px origin.y 将UIView添加到cell.contentView中,并在源于41px origin.y的单元格内容上方添加白色

A little late, but just in case anyone else is running into this issue. 有点晚了,但以防万一其他人遇到了这个问题。 If using IB, ensure "Clip Subviews" is checked on your table view cell. 如果使用IB,请确保在表格视图单元格中选中“剪辑子视图”。 And this: 和这个:

    self.contentView.clipsToBounds = YES;

should do the same thing. 应该做同样的事情。

You didn't solve this problem because the point is not the UITableViewCell. 您没有解决此问题,因为重点不是UITableViewCell。 It's Aspect Fill Mode of UIImageView. 这是UIImageView的纵横比填充模式。

Select the UIImageView in the SB, check this on! 在SB中选择UIImageView,选中此按钮!

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM