How to check in which position (landscape or portrait) os the iPhone now?
Posted
by Mike Rychev
on Stack Overflow
See other posts from Stack Overflow
or by Mike Rychev
Published on 2010-03-25T14:49:55Z
Indexed on
2010/03/25
15:03 UTC
Read the original article
Hit count: 361
I have an app with a tab bar, and nav controllers in each tab. When user shakes the device, a UIImageView appears as a child view in the nav controller. But the UIImageView must contain a special image, depending on the device's current orientation.
If I write just
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)
if (interfaceOrientation == UIInterfaceOrientationPortrait|| interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
//Code
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight||interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
//Code
}
}
The view just goes crazy if user rotated the device before shaking. Is there a method to get iPhones current orientation?
© Stack Overflow or respective owner