I have a UIWebview
that is loaded as a subview when a user selects a tab on a UISegmentedControl
. For some reason, I can not get it to allow pinch/zooming
.
I set the following code in the viewDidLoad:
method, so it should work.
self.myWebView = [[[UIWebView alloc] initWithFrame:self.view.frame] autorelease];
self.myWebView.backgroundColor = [UIColor whiteColor];
self.myWebView.scalesPageToFit = YES;
self.myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.myWebView.delegate = self;
[self.view addSubview: myWebView];
I tried loading a UIWebView
from a NIB and creating it programmatically with no avail. Is there something I'm missing? What could be causing the webview to ignore pinching and zooming?
Thanks!
[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.zoom = 5.0;"];
seem to be the suitable solution
I solved this with setting a view port:
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.5; user-scalable=1"/>
Good luck
I see you are setting the autoresizingMask
. Does that mean you have created the UIWebView
with an initial size of CGRectZero
? Can you interact with the document at all? I mean, does scrolling/tapping work?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With