tableView:moveRowAtIndexPath:toIndexPath: on iOS 3.x gets called over and over again when moving rows
As the topic says, this method gets called over and over again when I move rows and crashes. It works fine on iOS 4.x
- (void)tableView:(UITableView *)tableView moveRo开发者_JS百科wAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
NSUInteger fromRow = [fromIndexPath row];
NSUInteger toRow = [toIndexPath row];
id object = [[array objectAtIndex:fromRow] retain];
[array removeObjectAtIndex:fromRow];
[array insertObject:object atIndex:toRow];
[object release];
[self reloadTableView];
}
-(void)reloadTableView{
[myTableView reloadData];
}
I don't have any idea why. Please help.
You don't need:
[self reloadTableView];
...or:
[myTableView reloadData];
If you have to reload, do this:
[myTableView performSelector:@selector(reloadData) withObject:nil afterDelay:1.0];
精彩评论