facebook

Portrait & Landscape Control

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #345635 Reply

    matrixmed
    Member

    Hi All,

    I am new to app building and new to Mobione so I hope you will be patient will my ramblings…

    What I am trying to do is have my app show an image and text in portrait view and when the user switches to landscape view the user would see a completely different image.

    Is this possible and if so, how would one do it.

    Thanks for your help.

    Chris

    #345657

    Code_A
    Member

    I am fairly new to M1 too, but I think you should be able to handle this in the Orientation change function in your “<designName>_custom.js” file located in your “<designName>-www” folder. Open the js file, find the postOrientationChange function, and just add your code to change between the images (see example below).

    phoneui.postOrientationChange = function(newOrientation) {
       
       var isLandscape = Math.abs(newOrientation);
    
          if(isLandscape){
    
             $('#m1-<designName>').css('background-image', 'url("images/LandScape460x320.png")');
    
          } else {
    
             $('#m1-<designName>').css('background-image', 'url("images/Portrait320x460.png")');
    
          }
    }

    I did a quick search on the forums and found some similar questions with example code included. Check out viewtopic.php?f=8&t=2526 and viewtopic.php?f=8&t=3960

    Hope this helps get you started.

    #345692

    matrixmed
    Member

    HI Code A

    Thanks for your help. I read both of the links provided and tried the code you provided. It did not solve our issue. I had seen that code tried in another post but the writer their said it didn’t work either.

    Do you have any other ideas.

    Thanks

    Chris

    #345721

    paulD
    Member

    Hi Chris

    Here is a quick and dirty example of a working project using the orientation to change content. Hopefully it will help you!

    Just a quick note that it doesn’t run in the new emulator but does in the old test centre and on the device. I have noticed that there are a few of my projects which have issues with the new emulator but work in the old emulator and chrome.

    Paul

    Attachments:
    You must be logged in to view attached files.
    #345730

    matrixmed
    Member

    Hi PaulD,

    That definitely gets me closer. The code kinda works.

    if I start the app with the phone in Portrait mode, it shows the landscape view. When I rotate the phone to landscape the view stays landscape. When i rotate the phone back to portrait, then it shows the portrait view.

    Anyway to fix that.

    Chris

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Portrait & Landscape Control

You must be logged in to post in the forum log in