Tuesday 9 July 2013

Reload UITableView particular row with animation.

To animate a batch insertion and deletion of rows and sections, call the insertion and deletion methods within an animation block defined by successive calls to beginUpdates and endUpdates. If you don’t call the insertion and deletion methods within this block, row and section indexes may be invalid. beginUpdates...endUpdates blocks are not nestable.
At the conclusion of a block—that is, after endUpdates returns—the table view queries its data source and delegate as usual for row and section data. Thus the collection objects backing the table view should be updated to reflect the new or removed rows or sections.
The reloadSections:withRowAnimation: and reloadRowsAtIndexPaths:withRowAnimation: methods, which were introduced in iPhone OS 3.0, are related to the methods discussed above. They allow you to request the table view to reload the data for specific sections and rows instead of loading the entire visible table view by calling reloadData.

 Example Code:

------------------------------------------------------------------------


 NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:0];//Indexpath for row which want to reload
   
    [tableView canCancelContentTouches];
    [tableView beginUpdates];
    [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:myIP]
                 withRowAnimation:UITableViewRowAnimationRight];//You can change animation option.
    [tableView endUpdates];

No comments:

Post a Comment