Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>UIWebView doesn't give you any progress information in the normal mode. What you need to do is first fetch your data asynchronously using an NSURLConnection. When the NSURLConnection delegate method <code>connection:didReceiveResponse</code>, you're going to take the number you get from <code>expectedContentLength</code> and use that as your max value. Then, inside the delegate method <code>connection:didReceiveData</code>, you're going to use the <code>length</code> property of the NSData instance to tell you how far along you are, so your progress fraction will be <code>length / maxLength</code> , normalized to between 0.0 and 1.0.</p> <p>Finally, you're going to init the webview with data instead of a URL (in your <code>connection:didFinishLoading</code> delegate method). </p> <p>Two caveats:</p> <ol> <li><p>It is possible that the <code>expectedContentLength</code> property of the NSURLResponse is going to be <strong>-1</strong> (<code>NSURLReponseUnknownLength</code> constant). In that case, I would suggest throwing up a standard UIActivityIndicator that you shut off inside <code>connection:didFinishLoading</code>.</p></li> <li><p>Make sure that any time you manipulate a visible control from one of the NSURLConnection delegate methods, you do so by calling <code>performSelectorOnMainThread:</code> - otherwise you'll start getting the dreaded EXC_BAD_ACCESS errors.</p></li> </ol> <p>Using this technique, you can show a progress bar when you know how much data you're supposed to get, and a spinner when you don't know.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload