Get device current orientation (App Extension)

后端 未结 10 1500
执笔经年
执笔经年 2020-12-09 10:02

How to get device current orientation in an App Extension, I have tried below two methods but no success.

  1. It always return UIDeviceOrientationUnknown

    <
10条回答
  •  渐次进展
    2020-12-09 10:49

    I found a way where we can calculate our device orientation like this way in (App Extension)

    - (void)viewDidLayoutSubviews
    {
       if(self.view.frame.size.width > self.view.frame.size.height)
          NSLog(@"Landscape");
       else
          NSLog(@"Portrait");
    }
    

    It gives me right orientation but still not get as device is LandscapeLeft or LandscapeRight as well as Portrait or PortraitUpsideDown.

    Still need help.

提交回复
热议问题