开发者

Preload UIView To Minimize Delay While Running Iphone App

I have an iphone app that has one view that needs to fetch a lot of data off of a variety of internet sites. Therefore, the amount of time required for it to load is unacceptab开发者_运维问答le. I was wondering if there is any way to load the view during the 'applicationDidFinishLaunching' method so the delay is at the startup of the app instead of midway through navigation.

Thank you very much!


You want to load the view as quickly as possible, and then launch a background thread or asynch request to pull the data down.

Making your application sleep during initial load isn't advisable. I believe SpringBoard will terminate any application which takes longer than 30 seconds to finish loading.

It's a bad user experience to have the app do something without visible feedback to the user (animated UIActivityView for example)


Have you already considered loading the data asynchronously? While it's loading, the UI doesn't get blocked. For example you can show a nice loading-wheel when your app is loading the data. This is how all good apps do this.


If the initial view has a separate viewController than your 'data' view, you could add a reference to the dataView to the appDelegate and then do something like:

if (self.curAccountManager == nil) {
    self.curAccountManager = [[accountManagerController alloc] initWithNibName:@"accountManager" bundle:[NSBundle mainBundle]];
    if (![self.curAccountManager isViewLoaded]) {
        UIView *tmpView = self.curAccountManager.view;
        tmpView = nil;
    }   



}

This will load the view. But if it's doing a lot of loading, when the user switches to it, it might not respond well. I would suggest you follow the suggestion above and in your data view load the data asynchronously so you can at least show the user status or partial results.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜