Получить текущую ориентацию устройства (расширение приложения)

Как получить текущую ориентацию устройства в расширении приложения, я попробовал ниже два метода, но безуспешно.

Всегда возвращать UIDeviceOrientationUnknown

[[UIDevice currentDevice] orientation]

На нем отображается красное сообщение о том, что «sharedApplication» недоступно на iOS (расширение приложения)

[[UIApplication sharedApplication] statusBarOrientation];

Я также добавляю наблюдателя, но мне не звонят.

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



- (void)notification_OrientationWillChange:(NSNotification*)n
{
   UIInterfaceOrientation orientation = (UIInterfaceOrientation)[[n.userInfo objectForKey:UIApplicationStatusBarOrientationUserInfoKey] intValue];

    if (orientation == UIInterfaceOrientationLandscapeLeft)
       [self.textDocumentProxy insertText:@"Left"];
    if (orientation == UIInterfaceOrientationLandscapeRight)
       [self.textDocumentProxy insertText:@"Right"];
}

Так что теперь, как кто-то может получить текущую ориентацию устройства.

Ответы на вопрос(10)

Ваш ответ на вопрос