When I have a UITableView as part of the visible view controller, how can I reload it so that the data I am looking at changes to the new data. Just calling reload doesn't seem to refresh the data until I scroll it.
4 Answers
Calling the reloadData
method refreshes the data as soon as the method is called. It does not wait for the table to be scrolled. Make sure the data source (array or dictionary or wherever you've saved the values) is changed before you call reloadData
.

- 2,011
- 7
- 29
- 40

- 70,519
- 61
- 198
- 274
-
7Doesn't seem to work with a custom table view cell. The data doesn't change until the table view is scrolled. Maybe I have a bug in my custom table view cell method. – Genericrich Mar 19 '09 at 05:32
-
1I use a custom cell too. Works great for me. You must've missed something in the code. Can you post the code. maybe we can find something – lostInTransit Mar 19 '09 at 06:34
-
2If you are using a nib-file to design your view, don't forget to connect the table you are calling reloadData on in the code to the table in your nib. It happens easily since you need to connect delegate and datasource as well. – jake_hetfield Apr 18 '12 at 07:30
-
I had the same problem with custom table view cells. I had to call the loadView method from ViewWillAppear for the cells to update without scrolling on subsequent loads. – IcyBlueRose Jun 23 '13 at 01:55
-
N.B. If you are in the UITableViewController this is `self.tableView.reloadData()` – dumbledad Sep 13 '16 at 09:02
Are you refreshing the data off the main thread? If so, you need to call the reloadData method using the following method:
- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait
So for a tableView it would be:
[tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];

- 635
- 8
- 9
Just a 2013 update, you should also be able to reload the data, just as long as you use
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
GCD is awesome!

- 8,865
- 12
- 42
- 60
-
This should be the accepted answer. If you hoped for simple reloadData to actually refresh the UI without any kind of interaction, this is the way to do it.. – Markus Apr 25 '15 at 22:32
-
Can you further explain why it should be executed on the main thread? – addlistener May 14 '15 at 10:54
The following code help you to reload table while you looking that:
[self.tableView reloadData];

- 101
- 7