问题
I am using default iOS 7's TableView Separator. I have custom cells of varying height. When scrolled up and down frequently some of the smaller cells leave behind their separators(perhaps, not sure if this is the cause). So the bigger cell gets cut right in the middle most of the times by the separator.
I have tried resetting cell's edge insets to their previous location but it does not seem to work
-(void)prepareForReuse
{
[self setSeparatorInset:UIEdgeInsetsZero];
}
回答1:
To avoid this use following steps -
Set cell separator edge inset as -
cell.separatorInset = UIEdgeInsetsMake(0.f, cell.bounds.size.width, 0.f, 0.f);
Set tableview footer view by zero view as-
self.tableview.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableview.width, 1)];
回答2:
Well, if you subclass UITableViewCell and override layoutSubviews
, then make sure you call super.layoutSubviews()
at the top of your function body.
Swift
override func layoutSubviews() {
super.layoutSubviews()
// do any customization here...
}
来源:https://stackoverflow.com/questions/25585378/uitableview-separator-appears-in-middle-of-cells-view