Reputation: 5345
I have a table which may have several hundred rows, all with different heights. Whenever a user deletes a row, the call:
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
takes a very long time to execute (around 2.5s).
Is there an alternative call to this one or any way to speed it up? Thank you!
Upvotes: 1
Views: 664
Reputation: 19996
Use the method estimatedRowHeight
of UITableView
to speed it up.
Providing a nonnegative estimate of the height of rows can improve the performance of loading the table view. If the table contains variable height rows, it might be expensive to calculate all their heights when the table loads. Using estimation allows you to defer some of the cost of geometry calculation from load time to scrolling time.
In any case you should measure with Instruments which parts of your code are taking up the most time.
Upvotes: 1
Reputation: 5957
You can try this. Its a bit unethical, but it works like a charm.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if([textArray count]>0){
[self deleteRowAtIndexPath:indexPath.row];
} //method fired when u select a row, which calls a method
}
-(void)deleteRowAtIndexPath:(int) indexPath{ //this method removes the data in the array from which the tableview is being populated
[textArray removeObjectAtIndex:indexPath];
[self.tableView reloadData]; //after deleting the data from the array it reloads the tableview
}
textArray is a NSMutableArray,from which the tableview is being populated.
But this dsnt have any animations.
Upvotes: 1