iPhone - 自动调整大小UIWebView内容不适合框架 [英] iPhone - Auto resizing UIWebView content do not fit the frame
问题描述
我正在我的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.
请看下面的截图:
Screeshot 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屋!