2

I have a UIWebView that loads a page hosted on a remote server. On document ready, it fires an asynchronous jQuery.ajax request to a server to populate a drop-down with a list of values returned from the server.

While it is loading the page and performing this request, I have a semi-transparent UIView and a UIActivityIndicator overlaying the UIWebView. I have implemented the webViewDidFinishLoad delegate method which removes the loading view.

  • In iOS 4/5, this delegate method is executed after the async request finished. This is the behaviour I want.
  • In iOS 6, this delegate method is executed before the async request finished and the loading view disappears too early.

Does anyone know if this is intentional. Any ideas how to resolve this problem?

Thanks!

Fergal Rooney
  • 1,330
  • 2
  • 18
  • 31
  • Are you sure that the request gets executed? Possibly the request gets cached as described here: [Is Safari on iOS 6 caching $.ajax results?](http://stackoverflow.com/questions/12506897/is-safari-on-ios-6-caching-ajax-results) – Marvin Emil Brach Sep 26 '12 at 07:26
  • Thanks for the response. The jQuery ajax request is using jsonp so there is a unique callback method passed as a parameter each time so it shouldn't cache it. I also validated using a proxy that the request was a 200 each time. The cache-control response header from the server is also "no-cache". One of the answers in that link you provided suggested having "no-cache" resolved to issue they were having. – Fergal Rooney Sep 26 '12 at 18:46
  • In the beta change logs, I see this: In iOS 6 and later, the UIWebView class paints its contents asynchronously. I wonder if its related to this? – Fergal Rooney Sep 27 '12 at 03:20
  • 2 Questions: Is the loader icon from Apple itself still showing in the status bar. And: is another request using the delegate? --- If it's a matter of repaint you easily could check by inserting an alert or any other notification when your delegate is used. – Marvin Emil Brach Sep 27 '12 at 06:32
  • Thanks for responding to my comments. I have posted my conclusion to this issue. – Fergal Rooney Oct 12 '12 at 15:48

1 Answers1

0

I have come to the conclusion that this was an intentional change. Essentially, as of iOS 6, webkit paints its contents asynchronously:

http://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/_index.html#//apple_ref/doc/uid/TP40012166-CH1-SW13

Therefore an asynchronous request on document load will be truly asynchronous. The UIWebView's delegate will be notified that the document has fully loaded while this request is executing. Prior to iOS 6, this notification would be executed after the asynchronous request finished. So the request was not truly asynchronous.

Fergal.

Fergal Rooney
  • 1,330
  • 2
  • 18
  • 31