iOS 6 auto rotate confusion

前端 未结 6 732
萌比男神i
萌比男神i 2020-12-29 17:08

I have my entire interface in one Storyboard. How can I make most of the ViewControllers only support a portrait orientation while only a couple supporting all orientations.

6条回答
  •  生来不讨喜
    2020-12-29 17:52

    Well i kinda hacked my way around this one. here is my Subclassed NavController.h

    #import "RootVC.h"
    
    @implementation RootVC
    
    -(BOOL)shouldAutorotate {
        def = [NSUserDefaults standardUserDefaults];
        return YES;
    }
    -(NSUInteger)supportedInterfaceOrientations {
        if ([def integerForKey:@"Should Rotate"] == 1) {
            return UIInterfaceOrientationMaskAllButUpsideDown;
        } else {
            return UIInterfaceOrientationMaskPortrait;
        }
    }
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
        return UIInterfaceOrientationMaskPortrait;
    }
    @end
    

    I just set an integer for @"Should Rotate" in defaults on each View Controller in

    - (void)viewWillAppear:(BOOL)animated
    

    works like a charm!

提交回复
热议问题