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

  • Home
  • SEARCH
  • 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 9002021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:30:51+00:00 2026-06-16T00:30:51+00:00

I have a UIWebview that loads a simple picture.The user needs to see the

  • 0

I have a UIWebview that loads a simple picture.The user needs to see the whole picture without the need of scrolling vertically. With the use of setSalesPageToFit:YES , The user had the image loaded but needed to scroll vertically to see the whole picture, how can i force the picture to show up entirely and no need to scrolling could be used?
This is my code snippet:

NSString *pathImg = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"1"] ofType:@"png"];
    NSString* webViewContent = [NSString stringWithFormat:
                                @"<html>"
                                "<body style='background-color: transparent' >"
                                "<div align='center'>"
                                "<img src=\"file://%@\"/ style='align:center;'>"
                                "</div>"
                                "</body></html>", pathImg];
      webView.backgroundColor =[UIColor clearColor];
    [self->webView loadHTMLString:webViewContent baseURL:nil];
    [webView setScalesPageToFit:YES];

Any help will be highly appreciated…

  • 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-16T00:30:51+00:00Added an answer on June 16, 2026 at 12:30 am

    Try this.. Hope it will help you

     NSString *htmlString = [NSString stringWithFormat:
                  @"<html>"
                  "<head>"
                  "<script type=\"text/javascript\" >"
                  "function display(img){"
                  "var imgOrigH = document.getElementById('image').offsetHeight;"
                  "var imgOrigW = document.getElementById('image').offsetWidth;"
                  "var bodyH = window.innerHeight;"
                  "var bodyW = window.innerWidth;"
                  "if((imgOrigW/imgOrigH) > (bodyW/bodyH))"
                  "{"
                  "document.getElementById('image').style.width = bodyW + 'px';"
                  "document.getElementById('image').style.top = (bodyH - document.getElementById('image').offsetHeight)/2  + 'px';"
                  "}"
                  "else"
                  "{"
                  "document.getElementById('image').style.height = bodyH + 'px';"
                  "document.getElementById('image').style.marginLeft = (bodyW - document.getElementById('image').offsetWidth)/2  + 'px';"
                  "}"
                  "}"
                  "</script>"
                  "</head>"
                  "<body style=\"margin:0;width:100%;height:100%;\" >"
                  "<img id=\"image\" src=\"%@\" onload=\"display()\" style=\"position:relative\" />"
                  "</body>"
                  "</html>",image path];
    
         [webView setClipsToBounds:YES];
        webView.opaque=NO;
        webView.backgroundColor=[UIColor clearColor];
        [webView setUserInteractionEnabled:NO];
        [webView sizeToFit];
        [webView setScalesPageToFit:YES];
        [webView loadHTMLString:htmlString baseURL:nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIWebView that loads text from an htmlString . I need when
I have a simple iOS native app that loads a single UIWebView. I would
I have a UIWebView that loads a link, http://www.google.com/a/datacommsales.net . But I want to
I have a UIWebView that loads a website. Then in - (void)webViewDidFinishLoad:(UIWebView *)webView I
I have a UIWebview that is loaded as a subview when a user selects
I have a UIWebView that loads a YouTube video. The problem is, that if
I have a Universal iOS app that loads certain pages into the UIWebView for
I have an app that loads a UIWebView. And that works well. It is
In my application, I have a UIWebview that loads linkedin auth page for login.
I currently have the following code that loads a UIWebView from another View. Now

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.