I have a simple app that downloads search results in XML when the user types in a UISearchBar
. The download+parsing is threaded and once done it fires an NSNotification
to tell the ViewController with the table view to [tableView reloadData];
Here is the code that receives the notification fired once results are in:
- (void)receivedResults:(id)notification { results = [notification object]; DLog(@"Received %i results",[results count]); [[self tableView] reloadData]; }
I get the log output "Received 4 results", but the table view doesn't reload the data until I scroll/drag it a couple pixels. I am using the built-in UITableViewCellStyleSubtitle
cell style and im not changing the height or ding anything fancy with the table view.
What am I doing wrong?
reloadData()Reloads the rows and sections of the table view.
Apple's SDK provides two components to help carry out such a task without having to implement everything from scratch: A table view (UITableView) and a collection view (UICollectionView). Table views and collection views are both designed to support displaying sets of data that can be scrolled.
A view that presents data using rows in a single column.
I was able to get the same thing to work. But the issue was that the reload data needed to be called on main thread.
dispatch_async(dispatch_get_main_queue(), ^{ [self.tableView reloadData]; });
I think this is more practical than the performSelectorOnMainThread option
Call
[self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
instead of
[self.tableview reloadData]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With