2014-09-19 31 views
0

我有用於播放視頻的應用程序。 正是在ios7偉大的,良好的工作,但現在在iOS8上它被打破當我在ios 8中旋轉它時MPMediaPlayer變小了

self.player = [[MPMoviePlayerController alloc] initWithContentURL:self.videoFileToDisplay]; 
[self.player play]; 

[self.view setBackgroundColor:[UIColor redColor]]; 
[self.player.view setBackgroundColor:[UIColor greenColor]]; 
UIView *playerView = self.player.view; 

[self.view addSubview:playerView]; 
playerView.translatesAutoresizingMaskIntoConstraints = NO; 
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[playerView]|" 
                    options:0 
                    metrics:nil 
                    views:NSDictionaryOfVariableBindings(playerView)]]; 
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[playerView]|" 
                    options:0 
                    metrics:nil 

還取決於水平或垂直視頻是我需要旋轉它

- (void)adoptVideoToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation withDuration:(NSTimeInterval)duration 
{ 

    CGFloat horizontalVideoAngle = 0; 
    CGFloat verticalVideoAngle = 0; 

    switch (toInterfaceOrientation) { 
     case UIDeviceOrientationLandscapeLeft: 
      horizontalVideoAngle = 0; 
      verticalVideoAngle = M_PI_2; 
      break; 
     case UIDeviceOrientationLandscapeRight: 
      horizontalVideoAngle = 0; 
      verticalVideoAngle = -M_PI_2; 
      break; 
     case UIDeviceOrientationPortraitUpsideDown: 
      verticalVideoAngle = 0; 
      horizontalVideoAngle = M_PI_2; 
      break; 
     case UIDeviceOrientationPortrait: 
      verticalVideoAngle = 0; 
      horizontalVideoAngle = -M_PI_2; 
      break; 
     default: 
      return; 
    } 

    CGFloat angle = [self isHorizontalVideo] ? horizontalVideoAngle : verticalVideoAngle; 
    self.player.view.transform = CGAffineTransformMakeRotation(angle); 
} 

這是善於所有方向除了肖像。即使倒置好 以下是截圖

portrait LandscapeRight UpsideDown LandscapeLeft

什麼是錯在iOS8上的縱向?

PS紅的觀點是MediaPlayer的上海華

回答

0

看起來蘋果在iOS8上改變旋轉背景,現在只旋轉內容,不會影響視圖幀。所以我結束了添加額外的比例變換