2014-11-18 8 views
0

У меня возникла проблема с поворотным видео youtube. Я добавил следующий код в свое приложение. И это работает для iOS 7. Однако это не для iOS8.Поворот видео youtube с iOS8

На моем взгляде, контроллер, я использовал следующий код:

 if(IS_OS_6_OR_LATER){ 
     // I use the following notification for iOS 7 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeStarted:) latername:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];//Notification 

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeFinished:) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];//Notification 
       }  



if (IS_OS_8_OR_LATER) { 
// I use the following notification for iOS 8 
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeStarted:) name:UIWindowDidBecomeVisibleNotification object:self.view.window]; 
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youTubeFinished:) name:UIWindowDidBecomeHiddenNotification object:self.view.window]; 
     } 



-(void) youTubeStarted:(NSNotification*) notif { 
    //Handle event 
      AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate]; 
      appDelegate.fullScreenVideoIsPlaying = YES; 
      NSLog(@"start fullscreen"); 
     } 
     -(void) youTubeFinished:(NSNotification*) notif { 
      AppDelegate* appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];//Notification 
      appDelegate.fullScreenVideoIsPlaying = NO;//Notification 
      NSLog(@"exit fullscreen");//Notification 
     } 



-(BOOL) shouldAutorotate { 
    //Handle rotate 
      NSLog(@"AutoState"); 
      return NO; 
     } 
     -(NSUInteger)supportedInterfaceOrientations{ 
    //Handle rotate 
      NSLog(@"AutoState 1"); 
      return UIInterfaceOrientationMaskPortrait;//Notification 
     } 
     - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ 
    //Handle rotate 
      NSLog(@"AutoState 2"); 
      return UIInterfaceOrientationPortrait;//Notification 
     } 

В прошивке 7, когда видео воспроизводится в ландшафтном режиме, я нажмите кнопку Готова, я вижу, журнал «AutoState 1» показан, однако я не видите этот журнал при работе с iOS 8. Можете ли вы помочь мне решить эту проблему на iOS 8? Большое спасибо

+0

Для правильного форматирования кода требуется время, чтобы его было легче читать. Предоставьте больше информации о вашей проблеме и ее контексте. – gareththegeek

+0

@gareththegeek: Извините, потому что я новичок. Мне очень жаль об этом – duy

+0

Кто может мне помочь? Пожалуйста!!!!!!! – duy

ответ

0

Вместо того, чтобы ограничивать все приложение портретом, а затем пытаться сделать видеоплеер доступным для пейзажа, вы должны позволить ландшафту повсюду, а затем ограничьте свои невидимые контроллеры представлений (или контроллер корневого представления) чтобы только портретный режим, как этот:

в настройках целевой, позволяют ландшафт вашего приложения:

enter image description here

в контроллере (ы) вид, добавьте это, чтобы ограничить его портретной ориентации:

-(NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskPortrait; 
} 
Смежные вопросы