Reputation: 4036
Please see the video for animation issue in UITableview. When I get the data from the API and refresh cell than the first cell animation issue when it is expanded.
I used below code for reload cell.
self.tblSpDirectoryView.reloadRows(at: [IndexPath(row: 3, section: 0)], with: .none)
I have also tried to belove solutions for that.
self.tblSpDirectoryView.beginUpdates()
self.tblSpDirectoryView.reloadRows(at: [IndexPath(row: 3, section: 0)], with: .none)
self.tblSpDirectoryView.endUpdates()
Before all above code, I have used only the reload.
self.tblSpDirectoryView.reloadData()
It was not helpfull for me. I have share video file for understanding please find video file here.
Upvotes: 0
Views: 627
Reputation: 269
Your first code is correct for reload section you are using swift 3 kindly try this code
let indexPath = IndexPath(item: row, section: 0)
tableView.reloadRows(at: [indexPath], with: .fade)
Animation is not happening correctly, if your table view is static kindly check height in both storyboard and tableview height delegate method, if you are using xib the check in that also.If the differs from the storyboard and in the code the it will reflect like this.
Upvotes: 0
Reputation: 4156
Try to add:
self.tableView.beginUpdates()
self.tableView.endUpdates()
Also you can try to calculate all your cells heights.
And pass them to the method tableView(_:heightForRowAt:)
Upvotes: 2