views:

3569

answers:

2

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.

+5  A: 

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.

lostInTransit
Doesn'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
I 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
+1  A: 

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];

xmr