Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12790

iOS: locking to landscape-(primary|secondary) inconsistent with screen.orientation.type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • None

    Description

      For me, using cordova-plugin-screen-orientation@2.0.1, screen.orientation.lock('landscape') works to lock the device into landscape mode. However, a new issue appears if I try to lock to "landscape-primary" or "landscape-secondary."

      Desired functionality:

      1. iOS device is initially locked in "portrait-primary" mode
      2. User is required to turn device to landscape mode, so screen.orientation.lock('landscape'); is called
      3. App should stick with orientation it went to, so if user turns phone upside down, it doesn't flip orientation

      To achieve this:
      Using the Hello Cordova app, I do the following to index.js

          // Add this to the receivedEvent() method
              console.log('Received Event: ' + id);
              window.addEventListener('orientationchange',app.orientationChanged);
      
          // Then add this to index.js after receivedEvent() method
          orientationChanged: function() {
              console.log("Orientation changed to " + screen.orientation.type);
              console.log("Locking orientation to " + screen.orientation.type);
              screen.orientation.lock(screen.orientation.type);
          }
      

      Actual functionality:
      When the app is run, instead of locking to a landscape mode and staying in place, it locks into landscape mode and then spins like it's party time!

      Attachments

        1. index.js
          2 kB
          Jason Vertucio
        2. cordova_info.txt
          1 kB
          Jason Vertucio
        3. index.js
          2 kB
          Jason Vertucio

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jvngd Jason Vertucio
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: