tableView performBath 이후에
scrollView contentOffset 이 쌩뚱맞은 위치에가있는다.
contentOffset.y가 0으로 reset되는데, 그 해결이다
var cellHeightsDictionary: NSMutableDictionary = [:]
...
// save height
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
cellHeightsDictionary.setObject(cell.frame.size.height, forKey: indexPath as NSCopying)
}
// height value 복원
override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
if let height = cellHeightsDictionary.object(forKey: indexPath) as? Double {
return CGFloat(height)
}
return UITableView.automaticDimension
}