Reputation:
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
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)
Programmatically :
objWebView.scalesPageToFit = true
Upvotes: 1
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
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