tableview beginupdates endupdates

Facing issue in Tvos, swift 4.2


Iam using tableview to laod data with image at left side of the cell and 2 labels on right side.On every cell focus iam updating height of cell using tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath). Iam increasing the cell height on focus and decreasing cell height when cell is not focused using beginupdates() end updates() in tableView(_ tableView: UITableView, didUpdateFocusIn context: UITableViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) . On fast scroll tableview scrolling performance is not smooth and last cell in the tableview is getting cropped. All the updates are happening in tableView(_ tableView: UITableView, didUpdateFocusIn context: UITableViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator).


func tableView(_ tableView: UITableView, didUpdateFocusIn context: UITableViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {


if(context.nextFocusedItem as? tableViewCell != nil) {

if(context.nextFocusedIndexPath != nil){

coordinator.addCoordinatedFocusingAnimations({ (animationContext) in

// doing the animations required like changing font,font size,text color ..etc

tableview.beginupdates()

tableview.endupdates()

}, completion: {

})

}

}

}


tableview scroll performance is laggy. Last cell height is not updating on fast scroll and hence last cell in the tableview in getting cropped .

can you suggest solution to increasse the height of the cell without cell cropping issue and for smooth scrolling