How to update a UITableVIewCell without reloading full table

44,140

Solution 1

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

Use this

Solution 2

You can use this..

NSArray *indexPathArray = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:1 inSection:0]];
//You can add one or more indexPath in this array...

[tblview reloadRowsAtIndexPaths:indexPathArray withRowAnimation:UITableViewRowAnimationFade];

Solution 3

You can get the cell object by -

UITableViewCell *cell = [table cellForRowAtIndexPath:indexPath];

now change its related values as per your object from data array. It should reflect in the table. Hope this helps.

Solution 4

You can reload particular image row using index path .

    [mainTableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                         withRowAnimation:UITableViewRowAnimationNone];

Solution 5

As you are making a GUI update, it's better to use reloadData rather then using any other methods. reloadData is the best way in your case to update the UITableView as it avoids inconsistency. The other thing which you can do is, you can add a condition in your cellForRowAtIndexPath and let execution happen only for the cell which is modified.

Share:
44,140

Related videos on Youtube

Newbee
Author by

Newbee

Nothing to say

Updated on July 09, 2022

Comments

  • Newbee
    Newbee almost 2 years

    Possible Duplicate:
    Is it possible to refresh a single UITableViewCell in a UITableView?

    In a sequence I am updating only a particular object in my list data(NSMUtableArray), once updated its value, To make the GUI update, I was reloaded the full table like below...

    [table reloadData];
    

    It worked fine, However in efficiency point, it is hanging little bit while I am scrolling, Is there any way to update only a particular cell without reload full table?

    thanks.

  • Newbee
    Newbee about 11 years
    I already added that object need to updates its value
  • amar
    amar about 11 years
    See my answer then @newbee
  • Fogmeister
    Fogmeister about 11 years
    This is wrong. There are several ways to updates parts of a UITableView. reloadRowsAtIndexPaths, reloadSections and reloadSectionsWithIndexTitles will all reload parts of a UITableView.
  • Rushi
    Rushi about 11 years
    @Fogmeister my sentence is incorrect. I meant to say the condition in which Newbee is trying to use it. I've edited my answer.
  • Newbee
    Newbee about 11 years
    it worked, but still the freezing is there while scrolling for this update also..
  • amar
    amar about 11 years
    Does your cell has images?
  • amar
    amar about 11 years
    Use lazy Loading for them
  • Supertecnoboff
    Supertecnoboff over 8 years
    @amar Does "lazy loading" basically mean asynchronous loading?
  • amar
    amar over 8 years
    @Supertecnoboff yeah its a tech slang which means the loading is lazy and comes after the cell has been loaded.
  • Mehul Chuahan
    Mehul Chuahan over 7 years
  • amar
    amar over 6 years
    @MehulChuahan thats actually wrong implementation we do not need begin and end updates for using reloadRows.It is needed only for insertrow and remove row
  • Felipe
    Felipe almost 6 years
    Thanks, mate. This worked wonderfully for me.

Related