2013-02-10 153 views
0

我有一个tabbarcontroller内“VideoLecturesDetails”,这个类有这个方法MPMoviePlayerViewController旋转问题

-(IBAction) playVideo{ 
    NSString *fileURL = [NSString stringWithFormat:@"%@" ,FileName]; 

    NSURL* videoURL = [NSURL URLWithString:fileURL];     
    MPMoviePlayerViewController* theMoviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL]; 
    [theMoviePlayer shouldAutorotate]; 
    [self presentMoviePlayerViewControllerAnimated:theMoviePlayer]; 
} 

-(BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers { 
    return NO; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ 
    return YES;//This allows all orientations, set it to whatever you want 
} 

所以在播放视频的自动旋转不工作,我怎么能使用此方法能自动旋转。

+0

什么版本的IOS的是什么呢? – 2013-02-10 15:05:53

+0

我正在使用IOS 6 – 2013-02-12 10:12:06

回答

1
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ 
return YES;//This allows all orientations, set it to whatever you want 

}

上面的代码不再可用在iOS 6中!你应该保留给使用iOS 5或更低版本的应用程序的用户。

在iOS 6中,你应该实行轮换如下:

在的appDelegate: 用途:代替

window.rootViewController = viewController 

[window addSubview:viewController.view]; 

,并添加:

- (NSUInteger) application:(UIApplication *)application 

supportedInterfaceOrientationsForWindow:(UIWindow *)window { 
return UIInterfaceOrientationMaskAll; 
} 

每次旋转时都会发生这种情况。

,并在您的视图控制器你要跟应增加以下内容:

-(BOOL)shouldAutorotate { 

    return YES; 
} 
-(NSUInteger)supportedInterfaceOrientations { 

     return UIInterfaceOrientationMaskAllButUpsideDown; 
}