iOS device orientation disregarding orientation lock

后端 未结 10 1284
天涯浪人
天涯浪人 2020-11-29 01:59

I want to query the orientation the iPhone is currently in. Using

[UIDevice currentDevice].orientation

works as long as the device isn\'t

10条回答
  •  隐瞒了意图╮
    2020-11-29 02:24

    The UIAccelerometer class continues to function when the device orientation is locked. You'll have to work out your own methods of turning its variables into orientation values, but it shouldn't be especially complicated.

    Have a play with Apple's AcceleromoterGraph sample app to see what values the accelerometer outputs in different orientations.

提交回复
热议问题