【问题标题】:Can we know iPhone "Portrait Orientation Lock" is On/Off我们可以知道 iPhone“人像方向锁定”是开/关吗
【发布时间】:2019-11-05 07:23:25
【问题描述】:

我想知道 iPhone 当前处于纵向模式还是横向模式。如果我强行打开“纵向模式”,那么就有办法以编程方式知道。

【问题讨论】:

标签: ios swift


【解决方案1】:

您可以简单地使用orientation 来获取当前设备的方向,

UIDevice.currentDevice().orientation

要检查人像模式,您可以这样做,

if UIDevice.currentDevice().orientation == .portrait {
    //add your code here...
}

这些可能是orientation 值,

public enum UIDeviceOrientation : Int {
    case unknown
    case portrait // Device oriented vertically, home button on the bottom
    case portraitUpsideDown // Device oriented vertically, home button on the top
    case landscapeLeft // Device oriented horizontally, home button on the right
    case landscapeRight // Device oriented horizontally, home button on the left
    case faceUp // Device oriented flat, face up
    case faceDown // Device oriented flat, face down
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-22
    • 2011-12-20
    • 2012-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多