SORU
12 Mart 2011, CUMARTESİ


Nasıl doğru yönünü değiştirmek İOS javascript ve Phonegap kullanarak seziyorum?

Kod JQTouch referans malzeme aramaya aşağıda bu yönelim testi buldum. Bu doğru mobil safari İOS simülatörü çalışır ama düzgün ™ kolu yok. Benim projem bu test sayfası öldüren aynı sorunu çalışıyor. Bir yolunu ™ oryantasyon değişikliği javascript kullanarak duygusu var mı?

Herhangi bir yardım mutluluk duyacağız.

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 iPod touch Orientation Events". */
            document.body.setAttribute("class","portrait");

            /* Add a descriptive message on "Handling iPhone or iPod touch Orientation Events"  */
            document.getElementById("currentOrientation").innerHTML="Now in portrait orientation (Home button on the bottom).";
            break; 

        case 90:
            /* If in landscape mode with the screen turned to the left, sets the body's class attribute to landscapeLeft. In this case, all style definitions matching the
               body[class="landscapeLeft"] declaration in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */
            document.body.setAttribute("class","landscape");

            document.getElementById("currentOrientation").innerHTML="Now in landscape orientation and turned to the left (Home button to the right).";
            break;

        case -90: 
            /* If in landscape mode with the screen turned to the right, sets the body's class attribute to landscapeRight. Here, all style definitions matching the
               body[class="landscapeRight"] declaration in the iPhoneOrientation.css file will be selected and used to style "Handling iPhone or iPod touch Orientation Events". */
            document.body.setAttribute("class","landscape");

            document.getElementById("currentOrientation").innerHTML="Now in landscape orientation and turned to the right (Home button to the left).";
            break;
      }
    }

CEVAP
22 Mart 2012, PERŞEMBE


Yaptığım şey bu:

<script>           
  function doOnOrientationChange()
  {
    switch(window.orientation) 
    {  
      case -90:
      case 90:
        alert('landscape');
        break; 
      default:
        alert('portrait');
        break; 
    }
  }

  window.addEventListener('orientationchange', doOnOrientationChange);

  // Initial execution if needed
  doOnOrientationChange();
</script>

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • ColdfusTion

    ColdfusTion

    3 Aralık 2007
  • Hey Nadine

    Hey Nadine

    24 Kasım 2006
  • hitcreatormusic2

    hitcreatormu

    21 Mayıs 2010