2011-04-10 6 views
3

내 MPMoviePlayerController보기가 다른보기 컨트롤러보기에 하위보기로 추가되었습니다. 동영상을 전체 화면으로 재생하고 시뮬레이터를 넘기면 동영상이 뒤집히지 않으며 부모보기도 표시되지 않습니다. 그러나 회전 방법 (아래의 검사 코드)에 return YES을 추가하면 원하는대로 전체 화면에있을 때 비디오가 회전하지만 부모보기도 회전합니다. 풍경이 디자인되어 있지 않기 때문에 원하지 않습니다. 상위 뷰에 대한 뷰. 동영상이 전체 화면이면서 상위보기가 아닌 경우에만 어떻게 회전 할 수 있습니까?MPMoviePlayerController 비디오를 회전하는 방법 (수퍼 뷰에서는 회전하지 않음)

여기 내가 사용하는 코드는 다음과 같습니다

- (void)viewDidAppear:(BOOL)animated { 

    NSBundle *bundle=[NSBundle mainBundle]; 
    NSString *moviePath = [bundle pathForResource:@"MainPageMovie" ofType:@"mp4"]; 
    NSURL *movieURL=[[NSURL fileURLWithPath:moviePath] retain]; 
    MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 
    theMovie.scalingMode = MPMovieScalingModeAspectFill; 
    theMovie.view.frame = CGRectMake(115.0, 156.0, 200.0, 150.0); 
    [self.view addSubview:theMovie.view]; 
    [theMovie play]; 

    [super viewDidLoad]; 
    self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor]; 
} 

그리고 회전 방법 :

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return YES; 
} 

답변

0

간단한 방법은을 표시 MPMoviePlayerViewController을 사용하는 것입니다 비디오에 대한

영화. 별도의보기 컨트롤러이므로이 옵션은 회전을 처리해야합니다.

MPMoviePlayerController를 하위보기로 추가하여 실제로 수행하려는 경우 앞에 어려운 작업이 있습니다. 기본적으로 UIDeviceOrientationDidChangeNotification을 청취하고 장치 방향에 따라 적절한 transform, boundscenter을 무비 플레이어보기에 적용해야합니다.

+0

그래서 기본적으로 전체 앱에 대한 가로보기를 디자인하거나 세로보기로 동영상을 계속 재생할 수 있도록 부모보기에 대한 가로보기를 디자인합니까? : P 어쨌든 고마워 :) 비디오를 별도의보기에 추가하려고 노력할 것이다. 이것은 내 문제를 해결한다 :) –

관련 문제