views:

32

answers:

2

Dear all,

My app allow user reorder rows in a view, but I want to reloadData after moving is done to change some thing (add some text to the first row).

I tried to reloadData in moveRowAtIndexPath method, but it makes the app hang because this method is called many time (according number of rows need to be moved) and the table view is reload many time.

So, I just want to know when the moving behavior is done then I reloadData in just one time. does anyone know about this? please help me. thanks you so much!

A: 
-(int)table:(UITable*)table movedRow: (int)row toRow: (int)dest
Aaron Saunders
It's seem this overload method is make sense, but It is not run
Son Nguyen
+1  A: 
- (void)doReload
{
  [myTable reloadData];
}

You can do [self performSelector:selector(doReload) withObject:nil afterDelay:0.1] in the moveRowAtIndexPath method but you can't call [myTable reloadData] directly because as you found it causes a loop. Basically you need to allow the table manipulation to finish and the run loop to get around to calling your method which then causes a reload of your table. This is a bit of a hack but it works well. Ordinarily you don't need reloadData at this point but you may be trying to do something out of the ordinary.

Adam Eberbach
Although we have to do some trick, but it work well, thanks
Son Nguyen