How to check in which position (landscape or portrait) is the iPhone now?

后端 未结 13 1190
旧巷少年郎
旧巷少年郎 2021-01-30 06:47

I have an app with a tab bar, and nav controllers in each tab. When user shakes the device, a UIImageView appears as a child view in the nav controller. But the

13条回答
  •  攒了一身酷
    2021-01-30 07:44

    And if you simply want whether the device is in landscape or portrait, a simple solution is (in Swift):

    var orientation = "portrait"
    if UIScreen.main.bounds.size.width > UIScreen.main.bounds.size.height {
       orientation = "landscape"
    }
    

提交回复
热议问题