iPhone - 自动调整 UIWebView 内容的大小不适合框架

2023-10-21移动开发问题
0

本文介绍了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 内容的大小不适合框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

恢复游戏 cocos2d
Resume game cocos2d(恢复游戏 cocos2d)...
2024-08-12 移动开发问题
6

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7