János János - 1 year ago 74
iOS Question

How to reload tableview after reordering a row? Rows have variable height

I let user to reorder rows in

. Because this event affects content - some numeric values in cells should be updated - in all the other rows, I call a
. And then strange effects occur.

I.e. cells seems overlapping when touching dragger, and some cell starts to move up and down. Its important to know, that cells height are varying.

The strange, that if I remove
, then all these phenomenons disappear. Only the content is invalid.

So how should I reload data after reordering?

UPDATE: What I have done meantime reconfiguring cells in
instead of call
end of the
. And it works 90% like I expect, but still rows are sometimes somewhat higher 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

Answer Source

I found here the answer: http://stackoverflow.com/a/4692563/239219

[tableView beginUpdates];
[tableView endUpdates];

This code forces UITableView to reload cell sizes only, but not cell contents.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download