简体   繁体   English

捏放大iPhone应用程序中的UIWebView

[英]Pinch To Zoom in UIWebView in iphone App

I am Developing simple App. 我正在开发简单的应用程序 I am accessing html pages on UIWebVIew . 我正在访问UIWebVIew上的html页面。 and I wanted to zoom that html pages with the help of zoom option 我想借助zoom选项缩放那些html页面

please help me out. 请帮帮我。

Zooming IN, OUT and Pinch are Built In feature of UIWebView . 缩放IN,OUT和PinchUIWebView的内置功能。 You don't need to write any code to achieve that. 您无需编写任何代码即可实现此目的。 Simply , Use your fingers. 简单地说,用你的手指。

On Simulator , you can use Option (Alt) and Shift Keys with Mouse . 在模拟器上,您可以使用鼠标 选项(Alt)Shift键。

Make your option Scale Page to Fit ON . 选择Scale Page to Fit ON

Try this below property 试试以下物业

webView.scalesPageToFit = YES; webView.scalesPageToFit = YES;

First of all set this property given below: 首先设置此属性如下:

    webView.scalesPageToFit = YES;

Then you have to set view port on meta data on the html string. 然后你必须在html字符串上的元数据上设置视口。 In my case head tag was empty. 在我的情况下,头标记是空的。 Thats why I just replaced head with the with head containing meta tag. 这就是为什么我只是用包含元标记的头部替换头部。

    htmlString = [htmlString stringByReplacingOccurrencesOfString:@"<head></head>"
                                                 withString:@"<head><meta name=\"viewport\" content=\"width=568\"/></head>"];
    [webView loadHTMLString:htmlString baseURL:nil];

Using Storyboard : 使用故事板:

There is built-in property of WebView 'Scales Page To Fit' which is false by default. WebView 'Scales Page To Fit'内置属性默认为false。

Select WebView -> Open Utilities Window -> Goto Attribute Inspector' Select WebView - > Open Utilities Window - > Goto Attribute Inspector'

Set 'Scales Page To Fit' to true (Checkmark it) 'Scales Page To Fit'为true(选中它)

Screenhshot1

Programmatically : 以编程方式:

objWebView.scalesPageToFit = true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM