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

后端 未结 13 1005
旧巷少年郎
旧巷少年郎 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:49

    Here are macros UIDeviceOrientationIsLandscape and UIDeviceOrientationIsPortrait

    so rather checking separately you can do it like this ...

    if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
    {
        // code for landscape orientation      
    }
    

    OR

     if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation))
     {
         // code for Portrait orientation       
     }
    
    0 讨论(0)
提交回复
热议问题