UIDevice currentDevice's “orientation” always null

后端 未结 5 1746
一生所求
一生所求 2020-12-18 00:23

As per the title. Calling [[UIDevice currentDevice] BeginGeneratingDeviceOrientationNotifications] has no effect.

DidRotateToInterfaceOrientation etc events are wor

5条回答
  •  一向
    一向 (楼主)
    2020-12-18 00:31

    this is as per iMeMyself said in the comments above - this samed me a lot of time and I think is the right answer so I wanted to highlight it here:

    UIDeviceOrientation interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
    
    if (UIInterfaceOrientationIsLandscape(interfaceOrientation))
    {
       //do stuff here
    }
    else if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
    {
    //or do stuff here
    }
    

提交回复
热议问题