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 7793069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:22:11+00:00 2026-06-01T22:22:11+00:00

The structure is as follows: View Tab Bar Controller Navigation Controller View Controller Navigation

  • 0

The structure is as follows:

  • View
  • Tab Bar Controller
    • Navigation Controller
      • View Controller
    • Navigation Controller
      • View Controller
    • Navigation Controller
      • View Controller
    • Navigation Controller
      • View Controller
    • Navigation Controller
      • View Controller
    • Navigation Controller
      • View Controller

The above controllers have been initialised in interface builder.

What I’m trying to do is add a right UIBarButtonItem to each navigation controller but not having any success.

Here’s what I’ve tried:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor clearColor];
    self.view.opaque = NO;
    self.tabBarController.view.frame = self.view.bounds;

    NSArray *currentViewControllers = self.tabBarController.viewControllers;
    NSMutableArray *updatedViewControllers = [NSMutableArray array];

    for (int i=0; i<currentViewControllers.count; i++) {
        UINavigationController *tempNav = [[UINavigationController alloc]init];
        tempNav = [currentViewControllers objectAtIndex:i];
        UIBarButtonItem *dismissButton = [[UIBarButtonItem alloc] 
                                          initWithTitle:@"Done"                                            
                                          style:UIBarButtonItemStyleBordered 
                                          target:self 
                                          action:@selector(dismissLibraryBrowser)];
        tempNav.navigationItem.rightBarButtonItem = dismissButton;
        [updatedViewControllers addObject:tempNav];
        [dismissButton release];
        [tempNav release];

        NSLog(@"Added controller number %d",i);
    }

    self.tabBarController.viewControllers = [NSArray arrayWithArray:updatedViewControllers];

    [self.view addSubview:tabBarController.view];
}

The code executes without any errors, but the button doesn’t appear. I’m sure I’ve misunderstood something here. Would appreciate some guidance.

  • 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-06-01T22:22:13+00:00Added an answer on June 1, 2026 at 10:22 pm

    You are over complicating things slightly with recreating viewControllers and temporary arrays. You just need to manipulate the objects loaded from the nib

    [self.tabBarController.viewControllers enumerateObjectsUsingBlock:^(UINavigationController *navigationController, NSUInteger idx, BOOL *stop) {
    
        UIViewController *rootViewController = [navigationController.viewControllers objectAtIndex:0];
    
        UIBarButtonItem *rightBarButtonItem  = 
          [[UIBarButtonItem alloc] initWithTitle:@"Done"                                            
                                           style:UIBarButtonItemStyleBordered 
                                          target:self 
                                          action:@selector(dismissLibraryBrowser)];
    
        rootViewController.navigationItem.rightBarButtonItem = rightBarButtonItem;
    
     }];
    

    As for the structure of your app – the docs for UITabBarController say

    When deploying a tab bar interface, you must install this view as the root of your window. Unlike other view controllers, a tab bar interface should never be installed as a child of another view controller.

    So I would suggest having a look at restructuring some stuff, if you need it only occasionally why not consider presenting it modally?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to skip a view in a Navigation Controller? My structure is
I am really confused i have a directory structure as follows. /foo/bar/project/ under project
I have the enum structure as follows: public enum MyEnum { One=1, Two=2, Three=3
I have a directory structure as follows Client_Site/ some_folder1/ some_folder2/ some_folder3/ Lots of files
I have a python data-structure as follows: A = [{'abc': 'kjkjl'},{'abc': 'hjhjh'},{'abc': '78787'}] How
The structure I'm trying to setup is as follows: /public_html repository (live) what the
I am referencing a COM structure that starts as follows: [scriptable, uuid(ae9e84b5-3e2d-457e-8fcd-5bbd2a8b832e)] interface nsICacheSession
My directory structure looks like follows. (i'm using ext mvc ) www.mysite.com/ext/designer.js www.mysite.com/ext/app/view www.mysite.com/ext/app/store
I'm building a site using mvc2 and have a structure like follows: Factory ->
We have two tables resembling a simple tag-record structure as follows (in reality it's

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.