相关疑难解决方法(0)

如何在iOS上使用Phonegap正确检测方向变化?

我在下面找到了这个方向测试代码,寻找JQTouch参考资料.这在移动Safari上的iOS模拟器中正常工作,但在Phonegap中无法正确处理.我的项目遇到了与杀死此测试页面相同的问题.有没有办法在Phonegap中使用JavaScript来感知方向变化?

window.onorientationchange = function() {
  /*window.orientation returns a value that indicates whether iPhone is in portrait mode, landscape mode with the screen turned to the
    left, or landscape mode with the screen turned to the right. */
  var orientation = window.orientation;
  switch (orientation) {
    case 0:
      /* If in portrait mode, sets the body's class attribute to portrait. Consequently, all style definitions matching the body[class="portrait"] declaration
         in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or …
Run Code Online (Sandbox Code Playgroud)

javascript iphone jqtouch ios cordova

174
推荐指数
7
解决办法
23万
查看次数

标签 统计

cordova ×1

ios ×1

iphone ×1

javascript ×1

jqtouch ×1