【问题标题】:iphone autorotate issueiphone自动旋转问题
【发布时间】:2011-05-11 07:12:13
【问题描述】:

我在我的应用程序中使用自定义标签栏(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];

【问题讨论】:

  • 在这里尝试使用编辑器的代码功能。

标签: iphone ios4 uitabbarcontroller autorotate


【解决方案1】:

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

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

...您是否尝试过按照 Apple 的设置?

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

但是...尝试添加:

shouldAutorotateToInterfaceOrientation

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-08
    • 1970-01-01
    相关资源
    最近更新 更多