[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
};