How to update a UITableVIewCell without reloading full table
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.
Related videos on Youtube
Comments
-
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.
-
Rushi about 11 yearsYou can check this if it helps solve your problem stackoverflow.com/questions/7040740/…
-
-
Newbee about 11 yearsI already added that object need to updates its value
-
amar about 11 yearsSee my answer then @newbee
-
Fogmeister about 11 yearsThis is wrong. There are several ways to updates parts of a UITableView. reloadRowsAtIndexPaths, reloadSections and reloadSectionsWithIndexTitles will all reload parts of a UITableView.
-
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 about 11 yearsit worked, but still the freezing is there while scrolling for this update also..
-
amar about 11 yearsDoes your cell has images?
-
amar about 11 yearsUse lazy Loading for them
-
Supertecnoboff over 8 years@amar Does "lazy loading" basically mean asynchronous loading?
-
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 over 7 yearsProper answer is here stackoverflow.com/questions/4448321/…
-
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 almost 6 yearsThanks, mate. This worked wonderfully for me.