2014-09-26 60 views
0

縱向應用程序加載橫向顯示的視頻。在iOS8中使用橫向正確狀態欄播放橫向視頻內部縱向應用程序

在iOS7中所有的工作都很好(小修正了這個也是iOS6),但是在iOS8中狀態欄雖然在橫向上顯示實際上顯示的是縱向狀態欄的大小,所以它只佔據了左上角60%的視頻如果在橫向上保持裝置)。

我正在使用的代碼如下:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    [planTitleLabel setText:[[ProgrammeHandler sharedHandler] 
          stringForElement:kPlanStringElementPlanTitle 
          onDay:0 inPlan:selectedPlan]]; 
} 

- (NSUInteger)supportedInterfaceOrientations{ 
    return 0; 
} 

-(void) viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 


    if ([[UIDevice currentDevice].systemVersion floatValue] < 7.0) { 
     [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:FALSE]; 
     [[UIApplication sharedApplication] setStatusBarHidden:TRUE withAnimation:UIStatusBarAnimationNone]; 
    }else if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0 && [[UIDevice currentDevice].systemVersion floatValue] < 9.0) { 
     [[UIApplication sharedApplication] setStatusBarHidden:TRUE]; 
    } 


    NSString *moviePath = [[ProgrammeHandler sharedHandler] pathForAsset:kAssetVideoIntro onDay:0 forPlan:selectedPlan]; 
    CGSize screenBounds = [[UIScreen mainScreen] bounds].size; 
    [whiteFadeView setFrame:CGRectMake(0, 0, screenBounds.width, screenBounds.height)]; 

    NSURL *videoURL = [NSURL fileURLWithPath:moviePath]; 
    moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL]; 
    [[moviePlayer view] setBackgroundColor:[UIColor blackColor]]; 
    [moviePlayer setControlStyle:MPMovieControlStyleNone]; 
    [moviePlayer setScalingMode:MPMovieScalingModeAspectFill]; 
    //For viewing partially..... 
    moviePlayer.view.transform = CGAffineTransformMakeRotation(M_PI/2); 
    [moviePlayer setScalingMode:MPMovieScalingModeAspectFill]; 
    [movieView setAlpha:0]; 

    [moviePlayer.view setFrame:[movieView frame]]; 
    moviePlayer.view.backgroundColor = [UIColor blackColor]; 

    [movieView addSubview:moviePlayer.view]; 

    [moviePlayer prepareToPlay]; 
    [moviePlayer play]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(playbackFinished:) 
               name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(hideControl) 
               name:MPMoviePlayerLoadStateDidChangeNotification 
               object:moviePlayer]; 

    [UIView animateWithDuration:0.5f delay:0.50f 
         options:UIViewAnimationOptionCurveEaseIn 
        animations:^{[movieView setAlpha:1];} completion:^(BOOL fin){ }]; 
} 

- (void) hideControl { 
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                name:MPMoviePlayerNowPlayingMovieDidChangeNotification 
                object:moviePlayer]; 
    [moviePlayer setControlStyle:MPMovieControlStyleFullscreen]; 
} 

我沒有看到這個問題,但不認爲它適用於我的情況。 iphone: rotation in mpmovieplayercontroller?

是否有人知道如何將狀態欄恢復爲全屏'寬度'?

回答

2

好的,今天再次看了這個之後,我注意到有一個錯誤,iOS7似乎很滿意,但它正確地在iOS8中拋出一個錯誤。對於具有相同問題的其他人:

該修復只是將轉換應用於moviePlayer本身而不是子視圖。例如

替換 moviePlayer.view.transform = CGAffineTransformMakeRotation(M_PI/2); 與 movieView.transform = CGAffineTransformMakeRotation(M_PI/2);

+0

謝謝,幫了我很多。 – venkat 2017-05-02 10:06:55

相關問題