2
votes

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

3

3 Answers

1
votes

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

1
votes

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/

1
votes

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