Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7002471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:55:56+00:00 2026-05-27T20:55:56+00:00

I’m playing with some sample code to try and figure out once and for

  • 0

I’m playing with some sample code to try and figure out once and for all how to make navigation controller (s) and a tab controller to work together. As a bonus without memory leaks.

Having problems as shown below…

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
        (NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] 
        bounds]] autorelease];

    // Override point for customization after application launch.
    UIViewController *viewController1 = [[[FirstViewController alloc] 
            initWithNibName:@"FirstViewController" bundle:nil] autorelease];
    UIViewController *viewController2 = [[[SecondViewController alloc] 
            initWithNibName:@"SecondViewController" bundle:nil] autorelease];

    self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:
         viewController1, viewController2, nil];
    self.window.rootViewController = self.tabBarController;
    self.navigationController = [[UINavigationController alloc] 
         initWithRootViewController:self.tabBarController]; <<<<

    [self.window makeKeyAndVisible];
    return YES;

In my main project I have an outlet for 4 different navigation controllers and I call each like so.

MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] 
      delegate];
[delegate.balNavController pushViewController:nextController animated:YES];

But this leaks and is causing problems.

Without using the interface builder, can someone advise me, in simple terms how I should be doing this, perhaps with a few lines of code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:55:57+00:00Added an answer on May 27, 2026 at 8:55 pm

    I strongly encourage your to pick up a copy of the Big Nerd Ranch Guide to iPhone Programming. It has excellent exposition and examples to get you proficient in the basics. Now on to your issues…

    A UITabBarController is set by giving it an NSArray of UIViewControllers or even UINavigationControllers. The Tab Bar doesn’t mind which.

    A UINavigationController is set by giving it a UIViewController that will be the root.

    Keep in mind that the Tab Bar is not a View Controller, so it cannot be the root of a Navigation Controller!

    Combining these is simply a matter of correct order. Here’s a generic example that hopefully illustrates this.

    - (BOOL)application:(UIApplication *)application 
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    {   
        // UIViewController with UINavigationBar
        UIViewController *firstViewController = [[UIViewController alloc] init];
        UINavigationController *firstNavController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
    
        // Custom subclass of UIViewController with UINavigationBar
        CustomViewController *secondViewController = [[CustomViewController alloc] init];
        UINavigationController *secondNavController = [[UINavigationController alloc] initWithRootViewController:secondViewController];
    
        // UIViewController without UINavigationBar
        UIViewController *thirdViewController = [[UIViewController alloc] init];
    
        // Set the NSArray of ViewControllers
        NSArray *viewControllers = [NSArray arrayWithObjects:firstNavController, secondNavController, thirdViewController, nil];
        // This array retains the controllers, so go ahead and release them now
        [firstNavController release]; 
        [secondNavController release]; 
        [thirdViewController release]; 
    
        // Set up the UITabBarController -  It now holds everything
        tabBarController = [[UITabBarController alloc] init];
        [tabBarController setViewControllers:viewControllers];
    
        // Add the Tab Bar Controller to the window.
        [window addSubview:[tabBarController view]];
        [window makeKeyAndVisible];
    
        return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.