I am testing a piece of code on the ios simulator you get from apple (xcode).
basically I am trying to reset the scaling when the user rotates the ipad but on the simulator it is so inconsistant. I originally had the basic code to say if orientation is 90 do this, if it is -90 do that and so on but if my original orientation is landscape or portrait it might screw up. is this behavior just with ios simulator or the same as ipad, i don’t have an ipad with me so i cannot verify
when i reset the scaling i am first removing the meta tag content all together then adding to content again because if i dont do so, it does not work at all
sample code would be, i have tried using device width, it just screws up. I dont want to use css because the content is fix width so i just need to rescale. is my method wrong? is there another tested approach? I used a switch statement before but i find the if much simpler. thank you
if (orientation == 0 || orientation == 180) {
viewport.attr("content", "");
viewport.attr("content", "user-scalable=no, initial-scale=1, minimum-scale=1, maximum-scale=1, width=990px");
}
else {
viewport.attr("content", "");
viewport.attr("content", "user-scalable=no, initial-scale=0.77, minimum-scale=0.77, maximum-scale=0.77, width=990px");
}
}
The XCode simulator is pretty good and i never had problems with it besides it sometimes react a bit slow to orientation changes.
If you would want to check it with JavaScript i think you would best try comparing the window.innerHeight to the window.innerWidth and see which one is largest.
I made a test page a while back which uses only CSS to test for certain media query things.
link: http://pm5544.eu/mp/
Notice that when in landscape orientation the device width and height do not change, this was (at least to me) a bit counter-intuitive, so it might be that the iOS devices give unexpected info sometimes.
May i ask why you don’t want to use CSS for this because it sounds like it is very doable.
PM5544.