Wednesday, 26 October 2016

Reload particular row and section

Row:  

[self.tablename beginUpdates];
 NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
 NSArray *indexPaths = [[NSArray allocinitWithObjects:indexPath, nil];
[self.tablename reloadRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];

 [self.tablename endUpdates];

         (OR)

// Build the two index paths
[self.tablename beginUpdates];
NSIndexPath* indexPath1 = [NSIndexPath indexPathForRow:3 inSection:2];
NSIndexPath* indexPath2 = [NSIndexPath indexPathForRow:4 inSection:3];
// Add them in an index path array
NSArray* indexArray = [NSArray arrayWithObjects:indexPath1, indexPath2, nil];
// Launch reload for the two index path

[self.tablename reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade];
 [self.tablename endUpdates];


Section:

[self.tablename beginUpdates];
[self.tablename reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationNone];
[self.tablename endUpdates];

                (OR)

 [self.tablename beginUpdates];
 NSRange range = NSMakeRange(0, [self numberOfSectionsInTableView:self.tablename]);
 NSIndexSet *sections = [NSIndexSet indexSetWithIndexesInRange:range];
 [self.tablename reloadSections:sections withRowAnimation:UITableViewRowAnimationFade];
 [self.tablename endUpdates];

No comments:

Post a Comment