iPhone - 自动调整 UIWebView 内容的大小不适合框架 [英] iPhone - Auto resizing UIWebView content do not fit the frame

查看:20
本文介绍了iPhone - 自动调整 UIWebView 内容的大小不适合框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 viewDidLoad 方法中生成了一个 UIWebView,它的尺寸很小(比如说 50x70).然后我把它放到一个超级 UIView 中.

I'm generating an UIWebView into my viewDidLoad method, with a tiny size (let's say something like 50x70). And then I put it into a super UIView.

我想让它的内容适合 webView 框架.为此,我写道:

I'd like to make its content fit the webView frame. To do this, I wrote :

        oneView = [[UIWebView alloc] initWithFrame:CGRectMake(x, y, W, H)];
        oneView.backgroundColor = [UIColor whiteColor];
        oneView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
        oneView.scalesPageToFit = YES;
        oneView.autoresizesSubviews = YES;

        [self.view addSubview:oneView];
        [oneView loadRequest:/*some request*/];

但是这样做,网页不会调整到 UIWebView 的框架.它似乎被缩放到其他东西,比 superview 的框架小,比 webview 的宽.

But doing this, the web page is not resized to the frame of the UIWebView. It seems to be scaled to something else, smaller than the superview's frame, and wider than the webview's one.

如果我将 webview 框架大小设置为整个 superview 的大小,就可以了.
我如何强制网页内容(真正的 www 内容)适合缩小的" UIWebView 的框架?

If I set the webview frame size to the whole superview's size, it's ok.
How may I force the web content (real www content) to fit the frame of the "reduced" UIWebView ?

推荐答案

答案是:你已经这样做了,但是有限制.

The answer is: you are already doing this but there are limits.

请看以下截图:

截图 1,scalesPageToFit YES 和 NO

两个 webview 的宽度相同.在较低的页面中,页面非常适合.

Both webview have the same width. In the lower one the page fits perfectly.

Screeshot 2,scalesPageToFit 两者都是 YES,但设置的宽度更小

两个 webview 都试图适应页面,但由于有大小限制,它不会.

Both webview try to fit the page but it won't as there is a size limit.

这篇关于iPhone - 自动调整 UIWebView 内容的大小不适合框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆