iOS: Device orientation on load

前端 未结 16 1899
遥遥无期
遥遥无期 2020-11-28 23:45

It seems that when my app loads, it does not know its current orientation:

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
if (o         


        
16条回答
  •  遥遥无期
    2020-11-29 00:28

    Everyone above posted very valid answers : but as an UPDATE: Apple's take : you should e using UIStatusBar orientations to read current orientation of the device:

    One way you could check the current orientation of the device is by using an int values as such, inside the viewDidLoad method :

        int orientationType = [[UIDevice currentDevice] orientation];
    

    where consider the following . . . - 1 = portrait (right way up) - 2 = portrait upside down - 3 = landscape (right) - 4 = landscape (left)

    and then you could use an IF statement to call a method after orientation is detected, so on and so forth:

    Hope this was slightly helpful to someone

提交回复
热议问题