Manpreet
Manpreet

Reputation: 9

Device orientation in iOS 6 iphone issue

Hi I have an Tab Bar based application. When I click on the third tab,the view which opens up has a tableview (AggregateMediaViewController). On didSelect of the rows, I open a video using 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:

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

    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

In the appDidFifnishLaunching: [window setRootViewController:tabBarController]; where the tabBarController is a subclass of OrientationTabBarController.

In AggregateMediaViewController, I have the following code:

- (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

Upvotes: 0

Views: 176

Answers (1)

Timur Mustafaev
Timur Mustafaev

Reputation: 4929

You need to subclass your parent controller and add rotation methods of your UIViewController. In your case it is UITabBarController. And set it as rootViewController in appDelegate:

[self.window setRootViewController:_myTabBarController];

Upvotes: 2

Related Questions