Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SASlideMenu force orientation of child view controller #102

Open
gallagth opened this issue Dec 5, 2013 · 2 comments
Open

SASlideMenu force orientation of child view controller #102

gallagth opened this issue Dec 5, 2013 · 2 comments

Comments

@gallagth
Copy link

gallagth commented Dec 5, 2013

I have a ViewController on which I want to force orientation so I tried:

-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}

-(BOOL) shouldAutorotate {
return NO; //also tried YES
}

  • (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft;
    }

This basically does nothing. All the orientations are still supported and the thing rotates. I think it's because my ViewController is embedded in several other controllers with SASlideMenu

SlideMenuRootViewController --> SASlideMenuViewController --> UINavigationController (fixed to landscape in storyboard) --> MyViewController

I don't know if this is an issue per se, I've checked SlideMenuRootViewController and SASlideMenuViewController but there's not much regarding orientation there.

@aiQon
Copy link

aiQon commented Jun 12, 2014

same issue here, bump

@aiQon
Copy link

aiQon commented Jun 12, 2014

a workaround which couples components unluckily can be:

Paste this in your AppDelegate.m

  • (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    NSUInteger orientations = UIInterfaceOrientationMaskPortrait;
    SASlideMenuRootViewController *rootController = (SASlideMenuRootViewController *)self.window.rootViewController;
    if(rootController){
    SASlideMenuViewController *leftMenu = (SASlideMenuViewController *)rootController.leftMenu;
    orientations = [leftMenu supportedInterfaceOrientations];
    }
    return orientations;

}

This means that you ask the leftMenu (the part that you implement yourself) to tell you the supportedInterfaceOrientation. However, the SASlideMenuViewController does not inherit it, so you need to craft it yourself. In my case, I remember the current UINavigationController in the leftMenu and delegate the method call there. The NavigationController delegates the call to the ViewController in charge, which answers finally. It works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants