Is iphoneOrientation() broken?

Howard Bornstein bornstein at designeq.com
Fri Jul 6 02:26:14 EDT 2012


Something strange is going on with iphoneOrientation() unless I'm missing
something.

According to the docs, there are two functions that return the orientation
of an idevice: iphoneDeviceOrientation() and iphoneOrientation(). They
appear to be very similar—in fact, I can't really determine the difference
between them, which may be part of my problem.

iphoneDeviceOrientation() returns the orientation of the device, returning
either unknown, portrait, portrait upside down, landscape left, landscape
right, face up, and face down.

 iphoneOrientation() is used to fetch the current *interface
orientation *returning
only portrait, portrait upside down, landscape left, landscape right. Other
than the fact that iphoneOrientation() can't determine if the phone is face
up or face down, they seem identical.

Therefore, you'd think if you called them both at the same time, they'd
return the same results. However that's not what I get.

I created a stack and placed two fields in it: F1 and F2.

In the stack script I have the following:

*on* openstack

   orientationchanged

*end* openstack

*on* orientationchanged

   *put* iphoneDeviceOrientation() into fld "F1"

   *put* iphoneOrientation() into fld "F2"

*end* orientationchanged



When I run this stack in the simulator (I've set the simulator to allow all
four orientations) and rotate the stack, I do not get the same values in
the two fields. F1 (which uses iphoneDeviceOrientation) displays what seems
to me to be the correct orientation. F2 (which uses iphoneOrientation)
seems to lag one orientation change behind F1. The only exception to this
is the first time orientationChanged is called (in which case both fields
display Portrait).

When the simulator starts up in normal Portrait mode, both fields display
Portrait. If I select Rotate Left from the Hardware menu, F1 contains
Landscape Right (I'm not sure why it isn't Landscape Left, but at least
it's consistent in how it displays its state) while F2 still contains
Portrait.

If I chose Rotate Left again from the Hardware menu, F1 now contains
Portrait Upside down (which seems correct to me) while F2 now
contains Landscape Right. I can continue this way, with F2 lagging one
orientation change behind F1. If I rotate the phone to the right instead of
the left, this pattern continues, with F2 lagging one orientation behind F1.

Why does this happen? They should both be getting the orientation change
message at the same time and according to the docs, they should both be
displaying the orientation exactly the same. What am I missing?


Regards,

Howard Bornstein
-----------------------
www.designeq.com



More information about the use-livecode mailing list