简体   繁体   English

iOS 6 iphone问题中的设备方向

[英]Device orientation in iOS 6 iphone issue

Hi I have an Tab Bar based application. 嗨我有一个基于Tab Bar的应用程序。 When I click on the third tab,the view which opens up has a tableview ( AggregateMediaViewController ). 当我单击第三个选项卡时,打开的视图有一个tableview( AggregateMediaViewController )。 On didSelect of the rows, I open a video using MPMoviePlayerViewController . 在didSelect的行上,我使用MPMoviePlayerViewController打开一个视频。 I want to set the the orientation of the this video whenever the orientation of the device changes. 我想在设备方向改变时设置此视频的方向。 I created a subclass of UITabbarController called OrientationTabBarController : 我创建了一个名为OrientationTabBarControllerUITabbarController的子类:

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

    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

In the appDidFifnishLaunching: [window setRootViewController:tabBarController]; 在appDidFifnishLaunching中:[window setRootViewController:tabBarController]; where the tabBarController is a subclass of OrientationTabBarController. tabBarController是OrientationTabBarController的子类。

In AggregateMediaViewController, I have the following code: 在AggregateMediaViewController中,我有以下代码:

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

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

But when I run the application, orientation does not work :( Please Help 但是当我运行应用程序时,方向不起作用:(请帮助

You need to subclass your parent controller and add rotation methods of your UIViewController . 您需要子类化您的父控制器并添加UIViewController旋转方法。 In your case it is UITabBarController. 在你的情况下,它是UITabBarController。 And set it as rootViewController in appDelegate: 并在appDelegate中将其设置为rootViewController:

[self.window setRootViewController:_myTabBarController];

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

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