Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's what you do:</p> <p>In your UI controller that owns the web view, make it a <code>UIWebViewDelegate</code>. Then where you set the URL to load, set the delegate as the controller:</p> <pre><code>NSString *urlAddress = @"http://dl.dropbox.com/u/50941418/2-build.html"; NSURL *url = [NSURL URLWithString:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webView loadRequest:requestObj]; webView.delegate = self; </code></pre> <p>And finally implement the <code>webViewDidFinishLoad:</code> to correctly set the zoom level:</p> <p><strong>This option will applicable from iOS 5.0 and ></strong></p> <pre><code>- (void)webViewDidFinishLoad:(UIWebView *)theWebView { CGSize contentSize = theWebView.scrollView.contentSize; CGSize viewSize = theWebView.bounds.size; float rw = viewSize.width / contentSize.width; theWebView.scrollView.minimumZoomScale = rw; theWebView.scrollView.maximumZoomScale = rw; theWebView.scrollView.zoomScale = rw; } </code></pre> <p>I hope this helps...</p> <p>Option B, you can try to alter the HTML (this example does the job but is less than perfect from an HTML parsing standpoint. I just wanted to illustrate my point. It does work for your example, and probably most cases. The inset of 40 can probably be detected programmatically, I didn't try to research that.</p> <pre><code>NSString *urlAddress = @"http://dl.dropbox.com/u/50941418/2-build.html"; NSURL *url = [NSURL URLWithString:urlAddress]; NSString *html = [NSString stringWithContentsOfURL:url encoding:[NSString defaultCStringEncoding] error:nil]; NSRange range = [html rangeOfString:@"&lt;body"]; if(range.location != NSNotFound) { // Adjust style for mobile float inset = 40; NSString *style = [NSString stringWithFormat:@"&lt;style&gt;div {max-width: %fpx;}&lt;/style&gt;", self.view.bounds.size.width - inset]; html = [NSString stringWithFormat:@"%@%@%@", [html substringToIndex:range.location], style, [html substringFromIndex:range.location]]; } [webView loadHTMLString:html baseURL:url]; </code></pre>
    singulars
    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