Problem : when I am in the bottom UITableView (and only when in the bottom) and tableView.beginUpdates()/ tableView.endUpdates()is called, UITableViewit bounces a little. I do not want this to be done.
Customization: I have a UITableViewc UITableViewCellsthat will have different sizes, and I use UITableViewAutomaticDimensionto sort the cells.
Example:
When I'm at the bottom UITableView, and I select the cell, which then causes a tableView.beginUpdates()/ tableView.endUpdates(), UITableViewscrolls / jumps up slightly.
Has anyone found a way to prevent jumping after calling tableView.beginUpdates()/ tableView.endUpdates(), but in the end UITableView?
While I am calculating all of mine UITableViewCellsmanually, I would prefer not to do this because I would like to take advantage UITableViewAutomaticDimension.
Code
Here is the code showing what happens between tableView.beginUpdates()/ tableView.endUpdates():
tableView.beginUpdates()
cell!.setNeedsUpdateConstraints()
cell!.updateConstraintsIfNeeded()
cell!.setNeedsLayout()
cell!.layoutIfNeeded()
tableView.endUpdates()
My viewWillAppear:
public override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.tableView.estimatedRowHeight = 150.0
self.tableView.rowHeight = UITableViewAutomaticDimension
self.tableView.reloadData()
self.tableView.setNeedsLayout()
self.tableView.layoutIfNeeded()
self.tableView.reloadData()
}
My heightForRow:
public override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
Update : the removal of cell!.setNeedsUpdateConstraints(), cell!.updateConstraintsIfNeeded(), cell!.setNeedsLayout()and cell!.layoutIfNeeded() from tableView.beginUpdates()/ tableView.endUpdates()means to stop jumping, but then my cell is not the size ...
Change . This happens only at the bottom UITableView .