Get device current orientation (App Extension)

后端 未结 10 1468
执笔经年
执笔经年 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:54

    I know it's late, but the mistake in this question was in this line:

    [[NSNotificationCenter defaultCenter] addObserver:self.view selector:@selector(notification_OrientationWillChange:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
    

    addObserver:self.view is wrong, the notification should be attached on self for being called. Work also on iOS8.

提交回复
热议问题