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

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

    You can also define constants to earn time :

    #define LANDSCAPE UIInterfaceOrientationIsLandscape(self.interfaceOrientation)
    #define LANDSCAPE_RIGHT [UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft
    #define LANDSCAPE_LEFT [UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight
    #define PORTRAIT UIInterfaceOrientationIsPortrait(self.interfaceOrientation)
    #define PORTRAIT_REVERSE [UIDevice currentDevice].orientation == UIDeviceOrientationPortraitUpsideDown
    

提交回复
热议问题