David Pollak
David Pollak

Reputation: 23

UITableView has loaded data

I have a subview where there is an uitableview that gets data from an online server (title, subtitle and image). When I click the button that shows the subview it takes a little time to get there using WiFi connection, but under 3G network it takes longer, so that you really feel the gap between loading the view and having pressed the button

what I'd like to do, is to display an uiactivityindicatorview when you press the button and after loading the view, and when it has loaded stop the activity indicator

how can I check that the uitableview has finished loading ? do you have other suggestions ?

Thanks in advance

Upvotes: 2

Views: 654

Answers (3)

Fran Sevillano
Fran Sevillano

Reputation: 8163

As the others said, if you are not using an asynchronous approach to this, I strongly suggest you to do so, because otherwise you will block your application for as long as the data is being downloaded.

With that said, you could show the activity indicator while the data is being loaded, and that is until the delegate method

- (void)connectionDidFinishLoading:(NSURLConnection *)connection

is called. Then, your table should be populated with the data and the indicator would dissapear.

I hope this helped you a bit

Upvotes: 1

jasonmadigan
jasonmadigan

Reputation: 31

Look into doing network operations asynchronously, rather than blocking the main UI's thread. ASIHTTPRequest is a really good library for this: http://allseeing-i.com/ASIHTTPRequest/

Upvotes: 1

Saa
Saa

Reputation: 1615

Use asynchronious requests or threading (take a look at NSOperation)

Upvotes: 1

Related Questions