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

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

    To addon to the already answered question:

    You use [[UIDevice currentDevice] orientation] which will yield one of these values:

    typedef enum {
       UIDeviceOrientationUnknown,
       UIDeviceOrientationPortrait,
       UIDeviceOrientationPortraitUpsideDown,
       UIDeviceOrientationLandscapeLeft,
       UIDeviceOrientationLandscapeRight,
       UIDeviceOrientationFaceUp,
       UIDeviceOrientationFaceDown
    } UIDeviceOrientation;
    

    The documentation can be found here - (orientation) and here - (UIDeviceOrientation).

    (I don't mean to claim the former anwser, but this information was to big for a comment.)

提交回复
热议问题