0

您好我有一个基于标签栏的应用程序。当我单击第三个选项卡时,打开的视图有一个 tableview ( AggregateMediaViewController)。在 didSelect 的行中,我使用MPMoviePlayerViewController. 每当设备的方向发生变化时,我都想设置此视频的方向。我创建了一个UITabbarController名为的子类OrientationTabBarController

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

    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

在appDidFifnishLaunching: [window setRootViewController:tabBarController]; 其中 tabBarController 是 OrientationTabBarController 的子类。

在 AggregateMediaViewController 中,我有以下代码:

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

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

但是当我运行应用程序时,方向不起作用:(请帮助

4

1 回答 1

2

您需要继承父控制器并添加UIViewController. 在您的情况下,它是 UITabBarController。并在 appDelegate 中将其设置为 rootViewController:

[self.window setRootViewController:_myTabBarController];
于 2012-10-31T12:51:25.380 回答