views:

124

answers:

1

Hello, Can you provide me some good link or example, on how to place a navigation controller upon a tabBar controller in iPhone without using Interface builder. i know to create tabBar controller . Plese tel me how to place a navigation in the view provided by tabBar controller.

A: 

If I understood you correctly, all you should have to do is create an NSArray with one or more UINavigationController instances and assign it to the UITabBarController's viewControllers property.

You'd have to adjust it, but something like this might work:

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];
zenzelezz