I allow the user to reorder the rows in the tableView . Since this event affects the content โ some numeric values โโin the cells must be updated โ on all other lines, I call reloadData on moveRowAtIndexPath . And then strange effects happen.
those. The cells appear to overlap when the dragger is touched, and some cells begin to move up and down. It is important to know that the height of the cells is different.
It is strange that if I remove reloadData from moveRowAtIndexPath , then all these phenomena will disappear. Only content is not allowed.
So, how do I reload data after reordering?
UPDATE: In the meantime, I reconfigured the cells in viewDidLayoutSubviews instead of calling reloadData end of moveRowAtIndexPath . And it works 90%, as I expect, but still the lines are sometimes slightly higher than they should.
override func tableView(tableView: UITableView, moveRowAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) { //.. reorderOccured = true } override func viewDidLayoutSubviews() { if reorderOccured { for cell in tableView.visibleCells() as! [UITableViewCell] { let ip = tableView.indexPathForCell(cell) if ip != nil { self.configureCell(cell, indexPath: ip!) } } reorderOccured = false } }
ios uitableview
Jรกnos
source share