iOS 6 AutoRotate In UiNavigationController

前端 未结 5 647
挽巷
挽巷 2020-12-10 08:46

I have UiNavigationController in my app. I want that only one screen will be able to rotate so i put in this class :

-(BOOL)shouldAutorotateToInterfaceOrient         


        
5条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 09:41

    For iOS 6, I am using the following code in my app, which allows you to specify rotation for each viewcontroller individually:

    AppDelegate.m -

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{NSUInteger orientations =UIInterfaceOrientationMaskAllButUpsideDown;
    if(self.window.rootViewController){
    UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
    orientations = [presentedViewController supportedInterfaceOrientations];
    }
    return orientations;
    }
    

    ViewController.m -

    - (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
    }
    

    Credits for the code originially I believe go to the Ray Wenderlich "iOS 6 by Tutorials" book. Ray Wenderlich website

提交回复
热议问题