Determining the Orientation of the screen rather than the orientation of the device

后端 未结 1 645
悲哀的现实
悲哀的现实 2021-02-12 13:25

The [[UIDevice currentDevice] orientation] method returns a number of orientations beyond the portrait and landscape orientation. I am well aware of checking to se

1条回答
  •  闹比i
    闹比i (楼主)
    2021-02-12 14:02

    Have you tried using UIInterfaceOrientationPortrait/UIInterfaceOrientationLandscape? I usually have pretty good results using these methods:

    if(UIInterfaceOrientationIsPortrait(viewController.interfaceOrientation)) {
        //do portrait work
    } else if(UIInterfaceOrientationIsLandscape(viewController.interfaceOrientation)){
        //do landscape work
    }
    

    You might also try UIDeviceOrientationIsValidInterfaceOrientation.

    These will only return the app's orientation, which may not be the same as the device's orientation.

    If those don't work, you can also try:

    [[UIApplication sharedApplication] statusBarOrientation]
    

    0 讨论(0)
提交回复
热议问题