Uitableviewcell Separator Disappearing in iOS7

UITableViewCell Separator disappearing in iOS7

I dumped the subview hierarchy of affected cells and found that the _UITableViewCellSeparatorView was set to hidden. No wonder it's not shown!

I overrode layoutSubviews in my UITableViewCell subclass and now the separators are displayed reliably:

Objective-C:

- (void)layoutSubviews {
[super layoutSubviews];

for (UIView *subview in self.contentView.superview.subviews) {
if ([NSStringFromClass(subview.class) hasSuffix:@"SeparatorView"]) {
subview.hidden = NO;
}
}
}

Swift:

override func layoutSubviews() {
super.layoutSubviews()

guard let superview = contentView.superview else {
return
}
for subview in superview.subviews {
if String(subview.dynamicType).hasSuffix("SeparatorView") {
subview.hidden = false
}
}
}

The other solutions proposed here didn't work consistently for me or seem clunky (adding custom 1 px footer views).

UITableViewCell Separator disappearing in iOS15

In you viewDidLoad function add this:

yourTableViewReference.fillerRowHeight = UITableViewCellSeparatorStyleSingleLine

UITableView cell's seperators disappear when selected

The cause of my issue was the fact I used a blue color shade to show a cell being selected. This shade however was a little too big. It was covering the seperator

Why my UITableView separators are missing when using custom cell?]

  • Check your cells height ,maybe it bigger than the height you set on the delegate method or on the storyboard!
  • Make them same you could see the separators

UITableViewCell separator not showing up

Is the UITableViewCell in IB associated with a UITableViewCell subclass that overrides drawRect:? If so, make sure you are calling the super implementation, as that's what draws the line at the bottom. If you are overriding layoutSubviews make sure no views are obscuring the bottom of the cell.



Related Topics



Leave a reply



Submit