So I have a tableView where I want to change the height of a cell when tapped. Well, actually, I am replacing it with a bigger cell. On tap, I call:
tableView.beginUpdates()
tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
tableView.endUpdate()
And then I modify my cellForRowAtIndexPath
to return the right new cell and height. The cell's height is being automatically calculated by overriding sizeThatFits
in the cell's implementation:
override func sizeThatFits(size: CGSize) -> CGSize {
return CGSizeMake(size.width, myHeight)
}
Oddly enough, after I do this, scrolling downwards is fine, but when I scroll upwards, the table jumps 5 or so pixels every second until I reach the top. After I reach the top of the table, the problem is gone and there is no jumping going in either direction. Any idea why this is happening? I imagine it has something to do with the new cell height displacing the other cells, but I can't see why the tableView is not taking care of this. Any help is appreciated!
Thanks!
EDIT: Added code from cellForRowAtIndexPath:
if self.openedCellIndex != nil && self.openedCellIndex == indexPath {
cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as ListCell
(cell as ListCell).updateWithDetailView(dayViewController!.view)
} else {
cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as ListCell
(cell as ListCell).updateWithData(eventDay: store.events![indexPath.row], reminderDay: store.reminders![indexPath.row])
}
return cell