2011-04-09 3 views
0

전 화면에서 전체 화면을 재생할 때 시뮬레이터를 수평으로 뒤집을 때 비디오가 튀어 나오지 않도록하는 비디오가 있습니다. iPhone의 가속도계에 따라 동영상을 뒤집을 수있는 방법은 무엇입니까? 도움이된다면 여기 Xcode에서 비디오를 가로로 뒤집기

비디오에 대한 코드입니다 :

- (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]; 
} 

답변

0

귀하의 MPMoviePlayerController 뷰는 다른 뷰 컨트롤러의 뷰에 서브 뷰으로 추가됩니다. 부모보기 컨트롤러에서 shouldAutorotateToInterfaceOrientation 메서드를 재정의 했습니까? 그냥 풍경 (수평) 회전을 찾고 있다면 , 당신은 다음과 같이 코드를 가질 수 있습니다

상황에있는 경우 것보다 큰 뷰 컨트롤러보기의 특정 파단 (회전하기 위해
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Overriden to allow any orientation. 
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)); 
} 
+1

'return UIInterfaceOrientationIsLandscape (interfaceOrientation); ' –

+0

Vera이 애플리케이션은 기본 애플리케이션이 아니며 뷰 중 하나에 회전을 추가하지 않았습니다. 모든 전망은 수직입니다. 전체 화면으로 볼 때 동영상을 회전시키고 싶습니다. 이 일을 할 수 있니? –

+0

비디오에서 해결 된 문제 :) 방금 코드에 코드를 추가했습니다 (예 :;). 하지만 문제는 시뮬레이터를 회전 할 때 다른 모든 뷰가 회전한다는 것입니다. 다른보기의 가로보기를 추가하지 않았습니다. 비디오의 회전 만 허용하려면 어떻게합니까? –

0

동영상 만 회전시킬 때) CGAffineTransform 초를 수행해야합니다. 이렇게하면보기의 크기를 조정하고 회전 등을 할 수 있습니다. AFAIK, 아마도 단일보기를 회전하기위한 최상의 경로 일 것입니다.

그러나 MPMoviePlayerViewController에 대해 자세히 알아볼 수 있습니다. this post을 보시면 문제를 해결 한 것 같습니다.