代码之家  ›  专栏  ›  技术社区  ›  suse

如何在不使用Interface Builder的情况下将导航控制器放置在iPhone的tabBar控制器上?

  •  0
  • suse  · 技术社区  · 16 年前

    你能给我提供一些很好的链接或例子吗,关于如何在不使用Interface builder的情况下在iPhone的tabBar控制器上放置导航控制器。

    1 回复  |  直到 15 年前
        1
  •  0
  •   zenzelezz AmitF    16 年前

    如果我正确地理解了你,你所要做的就是创建一个 NSArray 一个或多个 UINavigationController 实例并将其分配给 UITabBarController viewControllers

    你得调整一下,但这样可能会奏效:

    NSMutableArray* controllers = [NSMutableArray arrayWithCapacity:4];
    
    for (NSUInteger i = 0; i < 4; ++i)
    {
        UIViewController* innerController = [[[UIViewController alloc] init] autorelease];
        UINavigationController* outerController = [[[UINavigationController alloc] initWithRootViewController:innerController] autorelease];
        [controllers addObject:outerController];
    }
    
    [tabBarController setViewControllers:controllers animated:YES];
    
    推荐文章