Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to deal with UIDeviceOrientationFaceUp and UIDeviceOrientationFaceDown?

a noob question here.

i detect the orientation with:

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];

all is fine and dandy and I reposition my text fields and labels according to the reported orientation with

if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown)

and else{} for everything else

the problem that i only recently discovered is when the UIDevice reports UIDeviceOrientationFaceUp or UIDeviceOrientationFaceDown. how do I deal with this situation ? how do I know whether UIDeviceOrientationFaceUp and UIDeviceOrientationFaceDown is happening in Portrait or Landscape ? I know that the device is facing up or down, but I don't know if I should reposition everything to Portrait or Landscape.

thank you!

like image 828
EarlGrey Avatar asked Dec 12 '10 18:12

EarlGrey


1 Answers

Apple recommends against using device orientation for view layout. Instead, each view controller has an interfaceOrientation property, and UIApplication has a statusBarOrientation property, both of which will return the current interface orientation, which is suitable for view layout.

To monitor for changes, there are UIViewController methods like willRotateToInterfaceOrientation:duration: that will be called and notifications such as UIApplicationWillChangeStatusBarOrientationNotification that will be posted when an interface orientation change occurs.

like image 110
Justin Spahr-Summers Avatar answered Nov 15 '22 15:11

Justin Spahr-Summers