0

我有一个项目是标签栏控制器。每个选项卡通常都有一个 UINavigationController。我遇到的问题是:我需要一个带有很多导航的新标签(大约 30 个导航项分为 4-8 组。问题:我的导航栏已经满了(不能使用导航控制器(或栏)。什么我需要的是导航栏下方的导航(它有一个全局搜索栏和其他全局图标填充它)。我怎样才能最好地实现这个?

我现在拥有的:我在导航栏下方创建了一个 UIScrollView 作为我的“手动”导航栏。这是一个滚动视图,因为我不知道(未来)我将拥有多少个导航项“分组”(目前只有 4 个)。Each of these groups is represented by a UIButton, some of which should immediately present a view, and others which present a popover with further navigation items, which when selected will present a view.

问题:我想要在上面提到的导航视图下有一个“内容视图”,我可以在其中根据用户的导航选择呈现内容。我必须支持 iOS 5.0,所以我不能使用故事板容器视图(很遗憾)。我将展示 3 种类型(以后可能会更多)的内容视图,我想将它们创建为单独的视图控制器,然后在我提到的导航中选择合适的视图控制器。我可以使用第 3 方导航控制器吗?我必须“自己动手”吗?任何建议将不胜感激。

这是我需要实现的“拼凑”图片: 在此处输入图像描述

4

1 回答 1

0

我会将您所称的内容视图作为主视图的子视图,并将其用作您将添加 childViewController 视图的视图。如果您还没有阅读自定义容器控制器,您应该这样做,但使用它们的基本方法是这样的。

您在问题中显示其视图的控制器将是自定义容器控制器。您可以在 viewDidLoad 方法中加载初始控制器,然后在子视图中切换控制器(我称之为 self.containerView)以响应用户从滚动条中选择的内容:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    UIViewController *initial = [self.storyboard instantiateViewControllerWithIdentifier:@"InitialVC"];
    [self addChildViewController:initial];
    [initial.view.frame = self.containerView.bounds];
    [self.containerView addSubview:initial.view];
    self.currentController = initial;
}

-(void)switchToNewViewController:(UIViewController *) cont {
    [self addChildViewController:cont];
    cont.view.frame = self.containerView.bounds;
    [self moveToNewController:cont ];
}

-(void)moveToNewController:(UIViewController *) newController {
    [self.currentController willMoveToParentViewController:nil];
    [self transitionFromViewController:self.currentController toViewController:newController duration:.6 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{}
         completion:^(BOOL finished) {
             [self.currentController removeFromParentViewController];
             [newController didMoveToParentViewController:self];
             self.currentController = newController;
         }];
}

这应该给你基本的想法。我从我的一个测试项目中得到了这个,所以它可能需要一些调整。

于 2013-01-22T04:59:11.547 回答