あなたは混同しないでくださいUIDeviceOrientation
、そしてUIInterfaceOrientation
、それらは異なっていますが、それらの宣言によって示されるように関連しています
typedef enum {
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait,
UIDeviceOrientationPortraitUpsideDown,
UIDeviceOrientationLandscapeLeft,
UIDeviceOrientationLandscapeRight,
UIDeviceOrientationFaceUp,
UIDeviceOrientationFaceDown
} UIDeviceOrientation;
typedef enum {
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
} UIInterfaceOrientation;
UIDeviceOrientation
デバイスの向きを教えてくれます。UIInterfaceOrientation
インターフェイスの向きを示し、によって使用されUIViewController
ます。UIInterfaceOrientation
明らかに縦向きまたは横向きになりますが、値UIDeviceOrientation
があいまいになる可能性があります(、、UIDeviceOrientationFaceUp
)。UIDeviceOrientationFaceDown
UIDeviceOrientationUnknown
いずれの場合も[[UIDevice currentDevice] orientation]
、デバイスの向きに関係なく、UIViewController interfaceOrientation
プロパティが異なる可能性があるため、UIViewControllerの向きを決定しようとしないでください(たとえば、アプリが横向きにまったく回転しない場合は、可能[[UIDevice currentDevice] orientation]
です)。UIDeviceOrientationLandscapeLeft
viewController.interfaceOrientation
UIInterfaceOrientationPortrait
更新:
iOS 8.0以降、[UIViewController interfaceOrientation]
非推奨になりました。ここで提供される代替手段はです[[UIApplication sharedApplication] statusBarOrientation]
。これもを返しますUIInterfaceOrientation
。