【发布时间】:2014-05-03 06:11:21
【问题描述】:
接口方向和设备方向有什么区别? 两者看起来都一样,但它们之间的实际区别是什么?
【问题讨论】:
标签: ios device-orientation interface-orientation
接口方向和设备方向有什么区别? 两者看起来都一样,但它们之间的实际区别是什么?
【问题讨论】:
标签: ios device-orientation interface-orientation
界面方向可以是任何东西,与设备方向无关。设备方向是您所持设备的实际物理方向,这不是可变的;就是这样。如果你持有的是肖像,那就是肖像。但仅仅因为设备是纵向的,并不意味着你的界面也是纵向的。您可能要求您的应用仅提供横向方向,因此界面方向与设备方向不同。
【讨论】:
UIInterfaceOrientation而不是@987654322 @?
以下描述来自this site.
UIDeviceOrientation 是 UIDevice 类的一个属性,有以下几种可能的值:
UIDeviceOrientationUnknown - 无法确定 UIDeviceOrientationPortrait - 主页按钮朝下 UIDeviceOrientationPortraitUpsideDown - 主页按钮朝上 UIDeviceOrientationLandscapeLeft - 向右的主页按钮 UIDeviceOrientationLandscapeRight - 向左的主页按钮 UIDeviceOrientationFaceUp - 设备是平的,屏幕朝上 UIDeviceOrientationFaceDown - 设备是平的,屏幕朝下
UIInterfaceOrientation 是 UIApplication 的一个属性,只包含 4 种与状态栏方向对应的可能性:
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight, UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft (从文档复制)
例如,设备(实际的 iPhone 或 iPod)可能位于 UIDeviceOrientationLandscapeRight 中,但如果您的应用不支持它,它(您的应用)可能仍位于 UIInterfaceOrientationPortrait 中。
另外,要获取 UIDeviceOrientation,使用 [[UIDevice currentDevice]orientation],要获取 UIInterfaceOrientation,使用 [[UIApplication sharedApplication] statusBarOrientation]
【讨论】: