开发者

UITableView has loaded data

I have a 开发者_StackOverflowsubview 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


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


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/


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜