orientation weirdness

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

orientation weirdness

Post by adventuresofgreg » Mon Jun 20, 2011 5:09 pm

Hello: I am experiencing some odd issues with orientation control:

I use "on orientationChanged" to reconfigure elements on my page to fit either Portrait or Landscape. It all works fine on the simulator, but on the iPhone, sometimes (this is inconsistent), when the device is in portrait orientation, my app will display as if it were landscape (with the card beelding off the right hand side of the device, and a blank space below). Then it will start 'flickering' between correct portrait orientation and the incorrect landscape orientation.

on preopencard
if the environment is "mobile" then
put "portrait,portrait upside down,landscape left,landscape right" into theallowed
iphoneSetAllowedOrientations theallowed
end if
focus on nothing
send resizestack
end preopencard

on orientationChanged
send "resizestack" to me in 0 millisecs
end orientationChanged

on resizestack
put "portrait" into currentorient
if the environment is "mobile" then
put iPhoneDeviceOrientation() into currentorient
end if
if currentorient is "portrait" or currentorient is "portrait upside down" then
--move all the stuff to portrait orientation
set the loc of group navbuttons to 326,874
set the rect of group theplotdaily to 39,533,266,821
else
--move all the stuff to landscape orientation
set the loc of group navbuttons to 504,554
set the rect of group theplotdaily to 636,176,780,466
end if

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: orientation weirdness

Post by adventuresofgreg » Mon Jun 20, 2011 5:32 pm

ok - I read my post again, and realized that maybe I didn't need "on orientationchanged", so I removed it and it solved the issue.

However, when I START the iOS application, it still appears in the wrong orientation - even when I FORCE it to draw a portrait screen ie: on opencard, draw all the stuff in portrait layout). ANy idea why? Its almost as if on START, the device 'thinks' it is in landspace orientation when it is actually in Potrait. Even if I force the page to be drawn as portrait, it still ends up getting a resizestack message saying that the device is in landscape orientation.

Thanks

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: orientation weirdness

Post by jacque » Mon Jun 20, 2011 8:23 pm

adventuresofgreg wrote:ok - I read my post again, and realized that maybe I didn't need "on orientationchanged", so I removed it and it solved the issue.
Right, the orientationChanged message is sent before the actual change occurs, so if you position objects in response to that message it will use the existing orientation, not the new one. The resizeStack message is sent after the device has re-oriented, and that's the one to use for new placement of objects.
However, when I START the iOS application, it still appears in the wrong orientation - even when I FORCE it to draw a portrait screen ie: on opencard, draw all the stuff in portrait layout). ANy idea why? Its almost as if on START, the device 'thinks' it is in landspace orientation when it is actually in Potrait. Even if I force the page to be drawn as portrait, it still ends up getting a resizestack message saying that the device is in landscape orientation.
The app should start up in the orientation you've set in the Standalone Settings pane using the "Initial orientation" popdown menu. Is that set to one of the portrait choices?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: orientation weirdness

Post by adventuresofgreg » Mon Jun 20, 2011 11:05 pm

YA!! Thanks. I didn't know there was initial orientation setting. It was set to Portrait, but I didn't have the other supported Interface Orientations selected - which is weird because they should have been working at all - yet they were. ??

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: orientation weirdness

Post by adventuresofgreg » Tue Jun 21, 2011 3:07 pm

This is still a problem. I have the initial orientation set to Portrait, but when I launch, my first screen always shows up oriented as landscape IN a portrait orientation of the device. Any ideas?

on preopencard
if the environment is "mobile" then
put "portrait,portrait upside down,landscape left,landscape right" into theallowed
iphoneSetAllowedOrientations theallowed
end if
focus on nothing
send resizestack
end preopencard

on resizestack
put "portrait" into currentorient
if the environment is "mobile" then
put iPhoneDeviceOrientation() into currentorient
end if
if currentorient is "portrait" or currentorient is "portrait upside down" then
--move all the stuff to portrait orientation
else
--move all the stuff to landscape orientation

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: orientation weirdness

Post by jacque » Tue Jun 21, 2011 5:04 pm

Move the stuff in your preopencard handler into a preOpenStack handler. You need to set orientations before anything else runs.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply