user2223924
user2223924

Reputation:

Pinch To Zoom in UIWebView in iphone App

I am Developing simple App. I am accessing html pages on UIWebVIew. and I wanted to zoom that html pages with the help of zoom option

please help me out.

Upvotes: 2

Views: 6411

Answers (4)

Jayprakash Dubey
Jayprakash Dubey

Reputation: 36447

Using Storyboard :

There is built-in property of WebView ‘Scales Page To Fit’ which is false by default.

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

Set ‘Scales Page To Fit’ to true (Checkmark it)

Screenhshot1

Programmatically :

objWebView.scalesPageToFit = true

Upvotes: 1

Ujjal Suttra Dhar
Ujjal Suttra Dhar

Reputation: 846

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. 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];

Upvotes: 2

Bhavin
Bhavin

Reputation: 27225

Zooming IN, OUT and Pinch are Built In feature of UIWebView. 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.

Make your option Scale Page to Fit ON.

Upvotes: 10

Abha
Abha

Reputation: 1082

Try this below property

webView.scalesPageToFit = YES;

Upvotes: 5

Related Questions