2012-10-31 49 views
0

嗨,我有一個基於標籤欄的應用程序。當我點擊第三個標籤時,打開的視圖有一個表格視圖(AggregateMediaViewController)。在didSelect的行中,我使用MPMoviePlayerViewController打開了一個視頻。我想在設備的方向改變時設置此視頻的方向。 我創建稱爲OrientationTabBarControllerUITabbarController一個子類:iOS 6中的設備方向iphone問題

@implementation OrientationTabBarControllerViewController 
- (BOOL)shouldAutorotate { 
    NSLog(@"in shouldAutorotate tabbar is %@", self.viewControllers); 

    return YES; 
} 

- (NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskPortrait; 
} 

在appDidFifnishLaunching: [窗口setRootViewController:tabBarController]; 其中tabBarController是OrientationTabBarController的子類。

在AggregateMediaViewController,我有以下代碼:

- (BOOL)shouldAutorotate 
{ 
    NSLog(@"in shouldAutorotate of media"); 
    return YES; 
} 

-(NSInteger)supportedInterfaceOrientations {  
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown); 
} 

但是當我運行該應用程序,方向不工作:(請幫助

回答

2

你繼承你的父母控制器,並添加旋轉方法。您UIViewController在你的情況下,它是的UITabBarController並將其設置爲RootViewController的中的appDelegate:

[self.window setRootViewController:_myTabBarController]; 
+0

我已經alreday做過 – Manpreet

+0

嗨,隨着上述變化,方向工程,但我面對一些屏幕20像素的問題。但是,如果我刪除上面的行,20像素問題已解決,但方向不起作用。 Plesae幫助!!!! – Manpreet