iPhone - Auto resizing UIWebView content do not fit the frame(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 内容的大小不适合框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iPhone - 自动调整 UIWebView 内容的大小不适合框架


基础教程推荐
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01