27 Feb 2014

iPhone Development: Reload a particular row in TableView

Tags: #Reload a Row #Tutorial #UITableView #IOS 

Table-view is the most common control used in iPhone app development.It allow app developers to display data in a list form.Everyone is familiar with its implementation in iPhone SDK but few of us know that we can reload a certain row in table-view Ir-respective of loading a whole table-view by using reloadData method of UITableView.

To reload a particular row of a tableView we have a method name

- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation

As written above this method demands two parameters to be passed by us
1) Array of indexpaths
2) Type of animation we want to show when a particular table-view row reloads.Different types of rowanimations available for us and these are




So, one question arises here how can this method will be gets called, don't worry you can call this method using your table-view instance as shown below

   NSIndexPath *indxPath = [NSIndexPath indexPathForRow:5 inSection:0];
    [businessInfoTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indxPath] withRowAnimation:UITableViewRowAnimationAutomatic];

Note: In above code I am considering my table-view instance as businessInfoTableView and we are getting indexpath of our 6th row of the table-view.

No comments:

Post a Comment