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

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

    You can also use the interfaceOrientation property of the UIViewController class, if you are stuck and continuously getting UIDeviceOrientationUnknown from UIDevice.

    There's a good summary of why [[UIDevice currentdevice] orientation] can sometimes fail here: http://bynomial.com/blog/?p=25, especially if you want to detect the orientation quickly (for example, if you wanted to check right when the app comes out of the background).

提交回复
热议问题