Giving Portrait App Ability to Use Landscape

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Tester2
Posts: 102
Joined: Wed May 18, 2011 7:02 pm

Giving Portrait App Ability to Use Landscape

Post by Tester2 » Thu Jan 12, 2012 10:11 pm

I have an iPhone app that supports a Portrait orientation only.

I want the user to be able to rotate the device and change the orientation to Landscape.

What is the easiest way to go about making my app able to do this? (What functions to use in scripts...when to use them, etc)

I know there are certain functions (mobileOrientation) that let you trap what orientation the device is currently in. But then how do you make your app automatically respond to that orientation? Do you have two cards for each screen (portrait and landscape) and switch between the two?

Help is greatly needed and much appreciated.

Thanks bunches!

-Tester2

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Giving Portrait App Ability to Use Landscape

Post by Dixie » Thu Jan 12, 2012 10:50 pm

Tester2...

I have attached a stack that will allow you to rotate... It is a 'simple' example of rotation, only two handlers are used and you will find them in the card script. I would also suggest that you read page 25 of the iOS release notes....

be well

Dixie
Attachments
rotateDemo.livecode.zip
(1.79 KiB) Downloaded 337 times

SusanB
Posts: 111
Joined: Mon Nov 07, 2011 4:10 am
Contact:

Re: Giving Portrait App Ability to Use Landscape

Post by SusanB » Fri Apr 27, 2012 7:04 pm

I am grateful for this, and it worked! I have to use both portrait and landscape orientations in my app and need it to open in portrait. Now when I go to the card that needs landscape, when I rotate the phone it miraculously goes to landscape orientation. The problem is it looks terribly confusing when it first appears in portrait orientation. This is probably a ridiculous question, but is there something that can be done so that card automatically opens in the needed landscape orientation??

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Giving Portrait App Ability to Use Landscape

Post by Dixie » Fri Apr 27, 2012 7:24 pm

SusanB...

The card that you want to have open in 'landscape' mode... do you want it to stay locked in in landscape mode all the time that you are on that card ?

be well

Dixie

SusanB
Posts: 111
Joined: Mon Nov 07, 2011 4:10 am
Contact:

Re: Giving Portrait App Ability to Use Landscape

Post by SusanB » Fri Apr 27, 2012 7:32 pm

Yes, it is worthless in portrait!

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Giving Portrait App Ability to Use Landscape

Post by Dixie » Fri Apr 27, 2012 7:39 pm

susanB...

Have a look at page 27 of the iOS release notes, 'Controlling auto-rotation'... read about 'iphoneLockOrientation' and 'iphoneUnlockOrientation'. I would lock the orientation in a preOpenCard handler when you go to the 'landscape' card and then unlock the orientation in a closeCard handler of the card...

be well

Dixie

SusanB
Posts: 111
Joined: Mon Nov 07, 2011 4:10 am
Contact:

Re: Giving Portrait App Ability to Use Landscape

Post by SusanB » Fri Apr 27, 2012 7:58 pm

I knew you would point me to the release notes, and now I must confess my most humble ignorance as to where to find the release notes :( I've searched high and low, and I'm sure I've read them. Are they from the Apple Developer site or the RunRev site? Please excuse my cluelessness, and my deep thankfulness for your help.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Giving Portrait App Ability to Use Landscape

Post by Dixie » Fri Apr 27, 2012 8:02 pm


SusanB
Posts: 111
Joined: Mon Nov 07, 2011 4:10 am
Contact:

Re: Giving Portrait App Ability to Use Landscape

Post by SusanB » Fri Apr 27, 2012 8:06 pm

Bless you! I've been there before, obviously, but my foggy brain has trouble remembering where to go. Now it's bookmarked.

Klaus
Posts: 14235
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Giving Portrait App Ability to Use Landscape

Post by Klaus » Fri Apr 27, 2012 9:22 pm

Hi Susan,
SusanB wrote:I knew you would point me to the release notes, and now I must confess my most humble ignorance as to where to find the release notes :( I've searched high and low, and I'm sure I've read them. Are they from the Apple Developer site or the RunRev site? Please excuse my cluelessness, and my deep thankfulness for your help.
in LiveCode: Menu: Help -> iOS Release Notes

Best

Klaus

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Giving Portrait App Ability to Use Landscape

Post by Dixie » Fri Apr 27, 2012 9:31 pm

Klaus wrote:in LiveCode: Menu: Help -> iOS Release Notes
Of course... how stupid of me... :oops:

SusanB
Posts: 111
Joined: Mon Nov 07, 2011 4:10 am
Contact:

Re: Giving Portrait App Ability to Use Landscape

Post by SusanB » Sat Apr 28, 2012 3:01 am

Oh no, it's me again. (Now I remember having gone to the menu to find those release notes in the past....) The thing about getting in landscape orientation, is that it doesn't happen until you've tilted your device in that direction, right? So if you go to the card from being in portrait, it will still be in portrait until you rotate the device. Is there a way in preopencard to make it think you've rotated it to landscape before you actually do? I've tried to figure how to do that and just can't get it. Setting the stack dimensions to do that on preopencard works in development, but not on the device.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Giving Portrait App Ability to Use Landscape

Post by Dixie » Sat Apr 28, 2012 4:45 am

SusanB...

I don't really know what you want to accomplish, but have a look at this stack... I have just modified the one that was posted earlier in the thread. When the card first opens it is in portrait mode... when you rotate to landscape it displays a picture... a group is just hidden or shown depending on the orientation... maybe this will work for you...

be well

Dixie
Attachments
rotateDemo 2.livecode.zip
(116.76 KiB) Downloaded 289 times

SusanB
Posts: 111
Joined: Mon Nov 07, 2011 4:10 am
Contact:

Re: Giving Portrait App Ability to Use Landscape

Post by SusanB » Sat Apr 28, 2012 7:43 am

Dixie,

You gave me a great idea for a workaround. I see the light at the end of the tunnel. Thanks!

SusanB
Posts: 111
Joined: Mon Nov 07, 2011 4:10 am
Contact:

Re: Giving Portrait App Ability to Use Landscape

Post by SusanB » Sat Apr 28, 2012 7:35 pm

One last comment. Dixie: I am so thankful for your help. Now my problem is solved. All the knowledgable people who so generously share their expertise on this forum are my heroes. Maybe one day I can be of help, too. Say, if someone wants to know what a button is or something ;)

Post Reply