João Victor
João Victor

Reputation: 57

Interface Orientation with TabBarController

I am using a Tab Bar Controller in my app. In the most part of the app's behavior we have one single orientation (interfaceOrientationPortrait). But i have a view that runs a video in WebView. When i am running this video, the orientation remains portrait. I want to put for all orientations.

Well, i used the return type YES in my Video's class. Nothing has changed. I changed the return type to YES in my RootViewController class. Nothing has changed.

I would like to change the orientation only for the Video.

Upvotes: 1

Views: 399

Answers (2)

View controllers that are part of a tab bar controller won't rotate to an orientation if any of the tab bar controllers can not rotate to that orientation (at least if the tab bar is visible). So maybe you want to update all your controllers' method in order to let the rotation happen if the web view controller is visible on the tab bar controller.

If you need a deeper explanation, just ask. Good luck!

Edit (example code)

This is what could be your rotation methods for your tab bar controller view controllers:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ((self.tabBarController.selectedIndex == kMyWebViewControllerIndex))
    {
        return YES;
    } else
    {
        return (orientation == UIInterfaceOrientationPortrait);
    }
}

Upvotes: 1

Ismael
Ismael

Reputation: 3937

Is your web view in a view controller inside the tabBarController?

Try showing it in a modally presented view controller, it should work

Upvotes: 0

Related Questions