I have some strange issue with UITableView only in iOS 7.
UITableViewCellSeparator disappears above the first row and below the last row. S
Based on @ortwin-gentz's comment, this solution works for me in iOS 9.
func fixCellsSeparator() {
// Loop through every cell in the tableview
for cell: UITableViewCell in self.tableView.visibleCells {
// Loop through every subview in the cell which its class is kind of SeparatorView
for subview: UIView in (cell.contentView.superview?.subviews)!
where NSStringFromClass(subview.classForCoder).hasSuffix("SeparatorView") {
subview.hidden = false
}
}
}
(Swift code)
I use fixCellsSeparator() function after calling endUpdates() in some methods of my tableView, for example:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
// Perform some stuff
// ...
self.tableView.endUpdates()
self.fixCellsSeparator()
}
I hope this solution will be helpfull for someone!