How to get the iPhone view's current orientation or the device's last orientation?

Knodel picture Knodel · Aug 19, 2010 · Viewed 8.3k times · Source

In my app an image appears when user shakes the device. There are different images for landscape and portrait mode. If the iPhone's orientation is portrait or landscape, it works fine. But if it is UIDeviceOrientationFaceDown or UIDeviceOrientationFaceUp, the image should depend on the last orientation used, because the view is still displayed for this orientation.

How can I get the last orientation of the device?

Answer

Knodel picture Knodel · Aug 19, 2010

I've figured it out! I had to check the status bar's orientation!

[UIApplication sharedApplication].statusBarOrientation