So, I have a tableView where I want to change the height of the cell when clicked. In fact, I am replacing it with a larger cell. When pressed, I call:
tableView.beginUpdates()
tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
tableView.endUpdate()
And then I change my cellForRowAtIndexPathto return the right new cell and height. Cell height is automatically calculated by overriding sizeThatFitsin the cell implementation:
override func sizeThatFits(size: CGSize) -> CGSize {
return CGSizeMake(size.width, myHeight)
}
Oddly enough, after I do this, the scroll down is fine, but when I scroll up, the table jumps 5 or so pixels every second until I get to the top. After I get to the top of the table, the problem will disappear and there are no jumps in any direction. Any idea why this is happening? I suppose this has something to do with the new cell height offsetting the other cells, but I don't understand why tableView doesn't care about this. Any help is appreciated!
Thank!
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
source
share