繁体   English   中英

iOS 6 iphone问题中的设备方向

[英]Device orientation in iOS 6 iphone issue

嗨我有一个基于Tab Bar的应用程序。 当我单击第三个选项卡时,打开的视图有一个tableview( AggregateMediaViewController )。 在didSelect的行上,我使用MPMoviePlayerViewController打开一个视频。 我想在设备方向改变时设置此视频的方向。 我创建了一个名为OrientationTabBarControllerUITabbarController的子类:

@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);
}

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

您需要子类化您的父控制器并添加UIViewController旋转方法。 在你的情况下,它是UITabBarController。 并在appDelegate中将其设置为rootViewController:

[self.window setRootViewController:_myTabBarController];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM