简体   繁体   中英

UITableViewCell hidden content overlaps on other cells

I have a table,with settings that cell height is 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. 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 ]

You want to hide the content of cell that is below the 40px level? Add UIView to cell.contentView with white colour above the content of cell with 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. And this:

    self.contentView.clipsToBounds = YES;

should do the same thing.

You didn't solve this problem because the point is not the UITableViewCell. It's Aspect Fill Mode of UIImageView.

Select the UIImageView in the SB, check this on!

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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