-1

我在我的应用程序中使用自定义标签栏(3 个标签)。每个选项卡都由导航控制器控制,如下所示。问题是在自动旋转方向时,根控制器上的每个自动旋转都很好,但子控制器(shouldAutorotateToInterfaceOrientation)没有响应。

NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:3];

UINavigationController *localNavigationContriller;

  XXXViewController *mail;
  xxx = [[XXXViewController alloc] initWithTabBar];

  localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:xxx];
  [localNavigationContriller.navigationBar setBarStyle:UIBarStyleDefault];
  localNavigationContriller.navigationBar.tintColor = [UIColor colorWithRed:134/255.0 green:187/255.0 blue:34/255.0 alpha:1];
  [localControllersArray addObject:localNavigationContriller];
  [localNavigationContriller release];
  [xxx release];

  YYYViewController *rsvn;
  yyyy = [[YYYViewController alloc] initWithTabBar];


  localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:yyyy];
  [localNavigationContriller.navigationBar setBarStyle:UIBarStyleDefault];
  localNavigationContriller.navigationBar.tintColor = [UIColor colorWithRed:134/255.0 green:187/255.0 blue:34/255.0 alpha:1];
  [localControllersArray addObject:localNavigationContriller];
  [localNavigationContriller release];
  [yyyy release];


  TempController *tem;
  tem = [[TempController alloc] initWithTabBar];


  localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:calendar];
  [localNavigationContriller.navigationBar setBarStyle:UIBarStyleDefault];
  localNavigationContriller.navigationBar.tintColor = [UIColor colorWithRed:134/255.0 green:187/255.0 blue:34/255.0 alpha:1];
  [localControllersArray addObject:localNavigationContriller];
  [localNavigationContriller release];


  tabBarController.delegate=self;
  tabBarController.viewControllers = localControllersArray;

  [localControllersArray release];
4

1 回答 1

0

苹果有针对这种情况的具体指南:

http://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CombiningViewControllers/CombiningViewControllers.html#//apple_ref/doc/uid/TP40007457-CH104-SW8

...您是否尝试过遵循 Apple 的设置?

你上面的源代码是不可能的,它永远不会编译。您对问题的描述不完整(哪个根控制器出现故障?根导航或根选项卡?)。

但是......尝试添加:

shouldAutorotateToInterfaceOrientation

给你的一个控制器,并让每一个都做 NSLog。通常,您会发现其中一个(出乎意料地)正在接收该消息,但它的子代都没有。这通常意味着你没有告诉它它的一些孩子,但你应该能够缩小范围。

于 2011-01-31T18:52:37.003 回答