Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

temm

macrumors newbie
Original poster
May 19, 2009
14
1
Hi,

I have tabbar app where the second tab has a tableViewController.
When on the first tab i select the second tab the tableview shows up and all data is loaded.

The problem is, that the data is from the network and it takes 2-3 seconds to load. Until the data is loaded the UI of the tableview is not showen until all data is loaded.

How can i show the second tab with no data in the tableview and then reload the table data?

I've tried to use -viewWillAppear and -viewDidAppear but the UI is not showen until they both completely finish.

This is what i've tried

Code:
- (void)viewWillAppear:(BOOL)animated {
	
	dataArray = [[NSArray alloc] initWithObjects:@"", nil];
	
	[self.tableView reloadData];

	[super viewWillAppear:animated];

}


 - (void)viewDidAppear:(BOOL)animated {
	
        [self loadData]; //This will load the actual data into dataArray
	[self.tableView reloadData];
	  
        [super viewDidAppear:animated];
 }


Teo
 
How are you loading the data? Based on your statements, it sounds like you are doing this synchronously and overloading the methods that would give responsiveness to the UI. If you are doing it asynchronously, you can make the call and let the delegate callbacks update the table when the data is loaded.

So how exactly do you do loadData? Are you using NSURLConnection? Are you trying to use something like NSArray:: + (id)arrayWithContentsOfURL:(NSURL *)aURL?
 
I'm using a tcp socket and adding objects to an NSArray
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.