开发者

How to prevent short freeze view

开发者 https://www.devze.com 2023-03-31 05:03 出处:网络
i am creating an app like the \"PageControl\" example from Apple, however, the info from my view\'s are downloaded from a server, and sometimes when the connection is poor i got those short freeze vie

i am creating an app like the "PageControl" example from Apple, however, the info from my view's are downloaded from a server, and sometimes when the connection is poor i got those short freeze view.

My view's UI are created in a .xib file, and populated when the data is downloaded.

There is any way to show the page empty with just an activity, until all the info are downloade开发者_运维百科d??

Thanks


Do your requests Asynchronously.

If it were me, I would look at using ASIHTTPRequest http://allseeing-i.com/ASIHTTPRequest/ because I think it is a great library for doing http for the iPhone. You can set a selector to be called when your particular request is finished. So I would put a UIActivityIndicatorView on the view (with hide when stopped checked in IB), startAnimating, kick off the request, when the request returns, call stopAnimating and set all of your properties for your view.


Either you do as cdasher suggested, or you run the download process in a separate thread, with

[target performSelectorInBackground:@selector(foo)];

remember then to update your UI in the main thread with performselectoronmainthread

0

精彩评论

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