2

i meet a different issue in my app for iOS 6. i have a UITabBarController for the window's rootviewcontroller,and then i have 4 uiviewcontrollers in this tabbBarController, now i want twoof them is just display "UIInterfaceOrientationMaskPortrait",and the two others display in "UIInterfaceOrientationMaskLandscape", The problem is that when I tap from the one which display in "UIInterfaceOrientationMaskPortrait" to the other viewController which is UIInterfaceOrientationMaskLandscape , however the new selected viewcontroller is still "UIInterfaceOrientationMaskPortrait" ,but when i rotate the device, the new selected view controller is rotate to "UIInterfaceOrientationMaskLandscape" .....

so is there any way that can make the tabbarviewcontroller can autorotate when I tap the different viewControllers?

below is my code: 1. I had alerady use the subclass of the UITabBarController in TR_UITabViewController.m

-(NSUInteger)supportedInterfaceOrientations
{
    return [self.selectedViewController supportedInterfaceOrientations];
}

-(BOOL)shouldAutorotate
{
    return  [self.selectedViewController shouldAutorotate];
}
  1. also in appdelegate.m I implement the method

    • (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ NSUInteger orientations = UIInterfaceOrientationMaskAllButUpsideDown;

      if(self.window.rootViewController){ UITabBarController *presentedViewController = (UITabBarController *)self.window.rootViewController; UIViewController * currentVC=presentedViewController.selectedViewController;

      NSLog(@"currentVC info:%@",[currentVC description]);
      if ([currentVC isKindOfClass:[UIViewController class]]) {
          orientations = [currentVC supportedInterfaceOrientations];
         // self.tabBarController.=[currentVC supportedInterfaceOrientations];
      
      } else if([currentVC isKindOfClass:[UINavigationController class]]) {
      
          UINavigationController * nvc=(UINavigationController*)currentVC;
          UIViewController * vc=nvc.topViewController;
      
       orientations = [vc supportedInterfaceOrientations];
      }
      

      }

      return orientations; }

3.at last I have write the below two method in each view controller - (BOOL) shouldAutorotate ; & - (NSUInteger) supportedInterfaceOrientations

In ,worlds, can someone know that how to force change the Orientation when tap the different view controllers in tabbarviewcontroller?

4

0 回答 0