[UIDevice currentDevice].orientation
返回UIDeviceOrientation
:
屬性的值是表示設備的當前 方向恆定。此值表示設備的物理方向 ,並且可能與您應用程序的用戶界面的當前方向 不同。
你getWidthAndHeightForOrientation
功能需要一個UIInterfaceOrientation
參數:
應用程序的用戶界面的方向。
這些類型雖然相關,但不是相同的東西。您可以使用self.interfaceOrientation
從任何視圖控制器訪問當前的接口方向。UIInterfaceOrientation
有4個可能的值,同時UIDeviceOrientation
具有9:
typedef NS_ENUM(NSInteger, UIDeviceOrientation) {
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait, // Device oriented vertically, home button on the bottom
UIDeviceOrientationPortraitUpsideDown, // Device oriented vertically, home button on the top
UIDeviceOrientationLandscapeLeft, // Device oriented horizontally, home button on the right
UIDeviceOrientationLandscapeRight, // Device oriented horizontally, home button on the left
UIDeviceOrientationFaceUp, // Device oriented flat, face up
UIDeviceOrientationFaceDown // Device oriented flat, face down
};
// Note that UIInterfaceOrientationLandscapeLeft is equal to UIDeviceOrientationLandscapeRight (and vice versa).
// This is because rotating the device to the left requires rotating the content to the right.
typedef NS_ENUM(NSInteger, UIInterfaceOrientation) {
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
};
感謝鮑勃!我必須嘗試一下。 – 2012-05-18 21:40:56
很高興爲你效勞! – 2012-05-25 04:35:13