I have a added to the "viewport"
meta tag "width=device-width,initial-scale=1.0"
and on an iPad the page loads up fine in landscape mode, the it switches nicely to portrait and when I rotate it back to landscape it scales the page up and I have to pinch zoom it back to a 1 scale.
I can fix this by adding the "maximum-scale=1.0, user-scalable=no"
, but I was wondering if there is a way I could fix this without taking away from the user the ability to zoom in the page.
If you have any suggestions I would love to hear them,
Thanks!
------ Update ------
This is not an issue anymore in iOS7. And there is better fix by Scott Jehl on github scottjehl/iOS-Orientationchange-Fix that works for iOS6.
------ Original answer ------
Jeremy Keith (@adactio) has a good solution for this on his blog Orientation and scale
Keep the Markup scalable
<meta name="viewport" content="width=device-width, initial-scale=1">
Then disable scalability with javascript until gesturestart with this script:
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
var viewportmeta = document.querySelector('meta[name="viewport"]');
if (viewportmeta) {
viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0';
document.body.addEventListener('gesturestart', function () {
viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
}, false);
}
}