Portrait App - Add Landscape Rotation

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

Portrait App - Add Landscape Rotation

Post by Tester2 » Tue Jan 10, 2012 11:39 pm

I have an iPhone app that I have developed and put up on the App Store.

The app as is only supports a Portrait orientation.

I am looking to add the ability for the user to rotate the device and change the orientation to Landscape.

What is the easiest way to go about doing this? (What functions to use in scripts...when to use them, etc)

Thanks bunches!

-Tester2

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Portrait App - Add Landscape Rotation

Post by lohill » Wed Nov 19, 2014 8:50 pm

This seems like a pretty basic question. Is no one able to answer it? This is something I would like to be able to do.

As a side note, why would the following code be rejected with the message ( Can't find handler error near "mobileSetAllowedOrientations, char 1) in the OpenStack event.

Code: Select all

on openStack
  mobileSetAllowedOrientations "portrait,portrait upside down,landscape left,landscape right"
end openStack
I even tried it without the landscapes left and right just as the dictionary example and it was rejected. Also tried it in the OpenCard event with no luck.

Thanks,
Larry

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

Re: Portrait App - Add Landscape Rotation

Post by Dixie » Wed Nov 19, 2014 9:19 pm

Here is a simple example of 'orientation' ...
The handlers are in the stack script..:-)
Attachments
orientate.livecode.zip
(9 KiB) Downloaded 207 times

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Portrait App - Add Landscape Rotation

Post by Simon » Wed Nov 19, 2014 11:24 pm

Hi Larry,
mobileSetAllowedOrientations is for mobile only... won't run on the desktop so you'll have to check the environment before you run it.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Portrait App - Add Landscape Rotation

Post by lohill » Thu Nov 20, 2014 12:18 am

Thanks Dixie and Simon.

Regards,
Larry

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Portrait App - Add Landscape Rotation

Post by lohill » Thu Nov 20, 2014 6:50 pm

Very nice and very simple Dixie. My idea is to construct a set of flash cards where in portrait mode the problem will be displayed as:

7 (7 should be above the 9)
+ 9
---------

while in the landscape mode it will be

7 + 9 =

If I were to make two separate stacks (Stack1 and Stack2) where the first is played out in portrait order and the second in landscape order and made them so that they both contained the same numbers at any given time. Could I get away with using a 'resizeStack' like the one shown below:

Code: Select all

on resizeStack
   iphoneShowStatusBar
   
   if "portrait" is among the words of iphoneDeviceOrientation() then
     go to stack "Stack1"
      exit resizeStack
   end if
   
   if "landscape" is among the words of iphoneDeviceOrientation() then
      go to "Stack2"
      exit resizeStack
   end if
end resizeStack
That would seem a lot simpler than trying to put all the objects in the proper loc.

Larry

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

Re: Portrait App - Add Landscape Rotation

Post by Dixie » Thu Nov 20, 2014 9:22 pm

Larry...

I would just use the one card... have a look at the attached stack...
As it is set up, the numbers and the operator change each time the card is opened, but you could set it so that new numbers are provided after your 'student' has answered each question...:-)
Attachments
orientate2.livecode.zip
(9.46 KiB) Downloaded 183 times

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Portrait App - Add Landscape Rotation

Post by lohill » Tue Nov 25, 2014 12:18 am

Dixie,

If it is not too much trouble, I would sure like to know why the attached stack will not go to Landscape correctly. As you can see from the commented out lines I have tried the guts of the rotation in both resizeStack and orientationChanged. Also, the only functioning operation is addition.
Flash Cards.livecode.zip
(3.67 KiB) Downloaded 187 times
Thanks,
Larry

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Portrait App - Add Landscape Rotation

Post by lohill » Tue Dec 02, 2014 12:19 am

Well, I finally got it to work. I started with Dixie's orientate2 stack and slowly modified it by adding more buttons and objects to get it the way I wanted. It was a slow process because I tested and saved at regular intervals so as not to have to go back to the original in case I had problems. I still have yet to work out the details for the other operations and adjust the 'levels'.

Larry

Post Reply