1

Apple has flagged the app I'm working on because it takes (or can take) a while for the content to load into a UIWebView, meanwhile the user is stuck looking at a blank screen. I'm using the standard UINavigationController framework and pushing the viewController for webView from what I'll call the mainMenuController.

Is there any way that I can pre-load the content of the webView from the mainMenuController (before the webView shows), so there's no delay once the transition to the webViewController happens?

JohnK
  • 6,865
  • 8
  • 49
  • 75
  • What is the web view displaying? Do you really need a web view? Why does it take a long time (can the resource it's loading be downloaded and cached)? – Wain Oct 09 '13 at 21:10

3 Answers3

2

I don't think that Apple is necessarily against the slow-loading content as much as they are against the blank screen.

One way to fix this problem would be adding a placeholder HTML to your app, with a message that says that the actual data is being loaded. Load the bundled "Please wait" HTML from a file in your bundle (here is how to do it), then start the actual load. To get really fancy, add an activity indicator.

If you know that you are always loading the same view from the web, you may want to cache some or all of it, then load the cached version from a file for quick viewing, and start the reload in the background.

Community
  • 1
  • 1
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
  • The placeholder idea is interesting (thanks for the link), but not really in line with what the project manager wants. The problem with caching is that the first load can be slow--or is there some way to bake the cached page into the app itself? – JohnK Oct 09 '13 at 22:22
  • 1
    @JohnK Absolutely, you can load the first page, store it inside the bundle, and use it as your placeholder. – Sergey Kalinichenko Oct 10 '13 at 00:43
0

You could create the UIWebView and load it before you push the new view controller. Then when you instantiate/push the view controller, you can pass the web view to the destination view controller, and add it as a subview.

paulrehkugler
  • 3,241
  • 24
  • 45
0

In the view did load you call and make the respective loading functionality of the web view and then in

webViewDidFinishLoad method you just call the following code

    [self.view addSubview:self.webview];

this works fine after the complete loading of webdata's it will show the view with finished data's.

Prabhu Natarajan
  • 869
  • 1
  • 9
  • 13
  • What version of iOS did you test this on? In my experience in iOS 6, the web view will not load until it is actually put on the screen, but I haven't tested this in iOS 7. – Rob Napier Oct 10 '13 at 12:46
  • Did not work with iOS8 . . . Blank web view with : CGAffineTransformInvert: singular matrix. – Jasper Blues Oct 15 '14 at 04:46