UIWebView不会缩放内容以适应 [英] UIWebView does not scale content to fit

查看:105
本文介绍了UIWebView不会缩放内容以适应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个webview,它是层次结构中的顶层窗口,并且已声明如下所示。但是,它不会缩放页面以适应。虽然scalesPageToFit属性设置为YES,但页面左上角对齐,但未缩放。任何帮助将不胜感激。

I have a webview which is the top window in the hierarchy and has been declared as shown below. However, it does not scale pages to fit. Pages are top left aligned, but are not scaled, despite the scalesPageToFit property being set to YES. Any help would be greatly appreciated.

webLookupView = [[UIWebView alloc] initWithFrame:CGRectMake(16, 63, 289, 327)];
webLookupView.backgroundColor = [UIColor lightGrayColor];
webLookupView.dataDetectorTypes = UIDataDetectorTypeAll;
webLookupView.scalesPageToFit = YES;


推荐答案

我后来发现某些网页已正确缩放,但有些不是。对于未正确缩放的网页,javascript可用于控制缩放,如下所示:

I have subsequently discovered that some web pages are correctly scaled, but some are not. For web pages which are not properly scaled, javascript can be used to control zooming as follows:

NSString *jsCommand = [NSString stringWithFormat:@"document.body.style.zoom = 1.5;"];
[webLookupView stringByEvaluatingJavaScriptFromString:jsCommand];

这篇关于UIWebView不会缩放内容以适应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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