Zoom in zoom out in phoneGap for iOS

杀马特。学长 韩版系。学妹 提交于 2019-12-06 12:37:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!