【问题标题】:Difference between Interface Orientation and Device Orientation?接口方向和设备方向之间的区别?
【发布时间】:2014-05-03 06:11:21
【问题描述】:

接口方向和设备方向有什么区别? 两者看起来都一样,但它们之间的实际区别是什么?

【问题讨论】:

    标签: ios device-orientation interface-orientation


    【解决方案1】:

    界面方向可以是任何东西,与设备方向无关。设备方向是您所持设备的实际物理方向,这不是可变的;就是这样。如果你持有的是肖像,那就是肖像。但仅仅因为设备是纵向的,并不意味着你的界面也是纵向的。您可能要求您的应用仅提供横向方向,因此界面方向与设备方向不同。

    【讨论】:

    • 在项目设置中选择方向时,为什么可能的方向标记为设备方向,而这里明确指的是UIInterfaceOrientation而不是@987654322 @?
    • 顺便说一句,如果您解释了为什么在枚举中左右切换,您的答案会更好。这只是一种习惯,因此人们可以从主页按钮的位置判断界面方向,还是有数学原因?
    【解决方案2】:

    以下描述来自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]

    你也应该参考..http://forums.gamesalad.com/discussion/40216/difference-between-device-orientation-and-interface-orientation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-11
      • 1970-01-01
      • 2016-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多