Could someone please lead 开发者_开发知识库me in the right direction to finding out how to recognize that the iPhone has been rotated, using PhoneGap please?
Thanks! C.
If you are not familiar with phonegap, check out Jonathan Stark's great introduction.
If you are already familiar with phonegap and just need a code snippet, then take a look at the bug report here. As you can see, it appears there are some problems with watchOrientation in the current release but Shazron provides a workaround which I've copied here:
function onDeviceReady()
{
// do your thing!
document.addEventListener("orientationChanged", UpdateOrientation);
}
function UpdateOrientation(e)
{
switch(e.orientation)
{
case 0: // portrait
case 180: // portrait
// do your thing here
break;
case -90: // landscape
case 90: // landscape
// do your thing here
break;
}
}
精彩评论