loadhtmlstring image and text offset resolution with UIWebView in iOS

Source: Internet
Author: User

iOS with UIWebView loadhtmlstring after the picture and text offset, the picture is too large, over the screen, the text is too small. Or the picture is too small. The text is too big, in short it is uncoordinated.

Our need is to make the size of the picture change with the change of the screen. is to adapt to the screen dynamically. Then the font of the text is that we can control, can be large and small. To achieve this effect. We want to process the string before loading it with loadhtmlstring. How to deal with it? What's the principle?

Ways to handle Htmlstring:
  NSString *htmls = [NSString stringWithFormat:@"
The principle of handling htmlstring:

The principle is to use a for loop, get all the pictures, for each picture is processed once, so that the width of the picture is 100%, according to the screen width adaptive. Let the picture of high Atuo, self-adaptation. The font size of the text, can go to change font-size:15px, here I use is 15px. According to their own detailed needs to change it.

Another blogger maintains an iOS development support group

loadhtmlstring image and text offset resolution with UIWebView in iOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.