How to set device (UI) orientation programmatically?

后端 未结 10 1537
感情败类
感情败类 2020-11-30 01:14

Would like everything on the screen (UI) to be able to rotate from landscape left to right or vica versa.

How do I go about doing this? Is this private?

I

10条回答
  •  清歌不尽
    2020-11-30 02:10

    As suggested on a related thread shouldAutorotateToInterfaceOrientation is deprecated. Newer apps should leverage the following methods as described in Apple's UIViewController Class Reference until they themselves become deprecated:

    • shouldAutorotate,
    • preferredInterfaceOrientationForPresentation; and
    • attemptRotationToDeviceOrientation.

    From what I understand it's best to use different View Controllers for views which need to lock into (i.e. have a preferred) orientation mode which differs from the last.

提交回复
热议问题