问题
I am developing an learning type application for iOS using HTML5/PhoneGap, but facing some problem in zoom in zoom out features. As I know PhoneGap runs app inside the UIwebview. so Zoom in Zoom out feature should work automatically in PhoneGap, but it is not working, although it works on Safari browser. Could some please guide how can I implement this feature.
Although I also set uiwebview mutitouch enabled. inside mainviewcontrollers webviewdidfinish loading..
[theWebView setMultipleTouchEnabled:YES];
Thanks in advance. Please guide me
回答1:
Finally I implemented Zoom in Zoom out in my iOS phone gap app.
The solution i got is , you need to set scalesPageToFit property in main view controller's viewdidLoad method. and no need to change any HTML/js code
- (void) viewDidLoad
{
[super viewDidLoad];
self.webView.scalesPageToFit = YES;
}
Now its working.
回答2:
There is an another alternate solution I got. It needs to change the main/Root index.html file. Add a meta tag like this
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1.5, user-scalable=yes">
And no need to edit any file in native code like mainviewcontroller.m or similar other.
Its better working than previous solution.
来源:https://stackoverflow.com/questions/11395876/zoom-in-zoom-out-in-phonegap-for-ios