Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7965481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:10:10+00:00 2026-06-04T06:10:10+00:00

I am making use of the UIWebView to render some HTML. However, although the

  • 0

I am making use of the UIWebView to render some HTML. However, although the width of my webview is 320 my HTML is still shown full width and can be scrolled horizontally.

I want to achieve the same thing the native mail application achieves which is it fits all content within that width without zooming out – how does the native mail application render HTML like this?

Update

I thought making use of the viewport meta tag will help, but I couldn’t get this to work.

This is what is happening:

enter image description here

As you can see the content does not fit the device width. I’ve tried so many combinations of viewport meta tag. The below is an example of what happens when I try Martins suggestion.

Original HTML is can be found here.

The way this HTML is rendered by the native mail application is like so.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:10:12+00:00Added an answer on June 4, 2026 at 6:10 am

    Here’s what you do:

    In your UI controller that owns the web view, make it a UIWebViewDelegate.
    Then where you set the URL to load, set the delegate as the controller:

    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;
    

    And finally implement the webViewDidFinishLoad: to correctly set the zoom level:

    This option will applicable from iOS 5.0 and >

    - (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;  
    }
    

    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.

    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:@"<body"];
    
    if(range.location != NSNotFound) {
      // Adjust style for mobile
      float inset = 40;
      NSString *style = [NSString stringWithFormat:@"<style>div {max-width: %fpx;}</style>", self.view.bounds.size.width - inset];
      html = [NSString stringWithFormat:@"%@%@%@", [html substringToIndex:range.location], style, [html substringFromIndex:range.location]];
    }
    
    [webView loadHTMLString:html baseURL:url];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been making use of callbacks to reduce coupling between some C++ classes. To
I am making use of jQuery's .autocomplete plugin, and I would appreciate some assistance
I am making use of javamail and I am having trouble getting the HTML
We have some code that is making use of the new postMessage functionality in
I have some test classes that are making use of spring-batch, and hibernate. My
I stumbled upon some code the other day that was making use of query
I have see some apps making use of the extra space you find when
Is there a way we can query iptables programmatically without making use of shell
I'm making use of an API on the internet that is marshalling objects to
I am making use of a custom cursor on itemRenderers in a List component.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.