【发布时间】:2019-11-05 07:23:25
【问题描述】:
【问题讨论】:
-
这是您需要的东西吗? stackoverflow.com/a/38894646/3940673
-
我从stackoverflow.com/questions/49164302/…得到了正确答案。
【问题讨论】:
您可以简单地使用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
}
【讨论】: