views:

995

answers:

2

Hi
I have a UITableview that I load with data async so the tableview might appear without data.
I have tired the ReloadData method but the tableview remains empty until I scroll the tableview, suddenly the data appears.
The same thing happens when I load a tableview as a detailedview and switching between items, the previoud items data appears first and as soon as I scroll in the table view it shows the correct data.
My guess is that the ReloadData method works just fine, but I need to redraw the tableview somehow, any suggestions on how to solve this?

/Jimmy

A: 

I guess it wasn't reloaded.

When you scroll the cells to out of screen, then..

tableView: cellForRowAtIndexPath:

.... will be called. So It was reloaded.

I guess UITableView variable is not validate.

If you use UITableView as a main view, you can try this.

[self.view reloadData];

(sorry for my poor English..)

cappuccino
+1  A: 

You said you're populating content asynchronously but did you invoke the reloadData in the context of the main thread ? (and not via the thread that populates the content)

[yourUITableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];

yonel
Thanks that solved it =)the solution for monotouch is:InvokeOnMainThread(() => this.TableView.ReloadData());
Jimmy Engtröm