HOWto pinching to zoom on a UIWebView [JS-callback] iPhone, iPod Touch, iPad
in a Web view I use this code for Zoom :
<body id='body'>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt u,...
<script type="text/javascript" charset="utf-8">
body = document.getElementById('body');
// (in percents)
zoom = 100;
maxZoom = 200;
minZoom = 50;
zoomIncrement = 25;
function gestureEnd(event) {
var newZoom;
if (event.scale > 1.0) {
// increase size
开发者_如何学JAVA newZoom = zoom + zoomIncrement;
} else {
// decrease size
newZoom = zoom - zoomIncrement;
}
// don't exceed zoom boundaries
if (newZoom > maxZoom || newZoom < minZoom) {
return;
}
zoom = newZoom;
body.style.webkitTextSizeAdjust = zoom+"%";
}
body.addEventListener("gestureend", gestureEnd, false);
</script>
</body>
HOW CAN I HAVE FROM webview zoom variable value every pinch-event (to change the default value in the APP) ??
A sort of 'callback' method by JS to App..
If you want to get the value of a JS variable to use in App native Obj-C, maybe you can use stringByEvaluatingJavaScriptFromString
method.
精彩评论