2013-02-10 152 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; 
}