Detecting a device's orientation change is very useful when an image has to change or other event is necessary when designing a mobile site or building an app.
All that is necessary is just a few lines of code.
$(window).bind('orientationchange',function(e) {
switch(window.orientation) {
case 0:
alert("device rotated");
break;
case 90:
alert("device rotated again");
break;
case -90:
alert("device rotated yet again");
break;
}
});
Check out my new car app for iPhone in the iTunes App Store
No comments:
Post a Comment