Detecting iOS orientation change instantly

后端 未结 6 2147
忘掉有多难
忘掉有多难 2020-12-02 05:38

I have a game in which the orientation of the device affects the state of the game. The user must quickly switch between Landscape, Portrait, and Reverse Landscape orientati

6条回答
  •  Happy的楠姐
    2020-12-02 06:20

    @vimal answer did not provide solution for me. It seems the orientation is not the current orientation, but from previous orientation. To fix it, I use [[UIDevice currentDevice] orientation]

    - (void)orientationChanged:(NSNotification *)notification{
        [self adjustViewsForOrientation:[[UIDevice currentDevice] orientation]];
    }
    

    Then

    - (void) adjustViewsForOrientation:(UIDeviceOrientation) orientation { ... }
    

    With this code I get the current orientation position.

提交回复
热议问题