What's really going on behind the scene when you set the phone's orientation to landscape mode? When I traced out main screen's bounds and any subview's bounds, the width and height is still 320x480, rather than 480x320.
Any idea why?
Some apps don't support rotation, so your screen may not rotate even if Portrait Orientation Lock is turned off.
When on the main screen, under the orientation section, you will see a number of options like 'Auto-rotate OFF', 'Auto-rotate ON', 'Forced Portrait' and 'Forced Landscape'. As the names suggest, you can use these buttons as one-tap shortcuts to toggle the orientation of your device.
Ensure that you have enabled Auto-rotate for your tablet. To do this, swipe down on the tablet to display the status bar and touch Auto Rotate. Some mobile versions of apps do not support Landscape mode, so they may not be displayable in Landscape mode on the tablet.
Are you checking the bounds property or the frame property? Certain controls, especially UIViews that fill up the screen, appear to maintain the same frame in any orientation; I think that AppKit sets their transform property to rotate their contents.
You will probably find that the bounds property has the value that you expect it most of the time, but that the frame property does not.
This is a large topic, but I'll add what amounts to 0.02; comments are constrained to changes between portrait and landscape; i.e., not things like upside down, face up, face down, and unknown.
If a view is not listening for orientation changes then the frame and bounds will remain the same regardless of orientation.
If a view has registered to listen for orientation changes then the bounds may change; i.e., in landscape whole screen frame is <320,480> while bounds is <480,320>. This assumes:
a. you are either using a shouldAutorotateToInterfaceOrientation callback with appropriate YES return values, or
b. explicitly registering with the notification center to listen to UIDeviceOrientationDidChangeNotification.
Approach 2a will hold true only for views belonging to the app window's root view controller; that is, the view controller whose view was added first. Approach 2b can be used in conjunction with affine transforms and manual bounds changes to get proper orientation layout for views not governed by autorotation.
I found that if you are not using an UINavigationController you can get problems with your view not being given the correct view and frame bounds.
I was directly adding views to the UIWindow and had exactly this problem. But when I sandwiched a UINavigationController between the UIWindow and my UIViews the problem went away.
Hope that helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With