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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:06:49+00:00 2026-05-26T18:06:49+00:00

I have an app with a navcontroller created in the appdel. Each vc pushed

  • 0

I have an app with a navcontroller created in the appdel. Each vc pushed in has a block of code in the viewdidload that sets up the toolbar. The toolbar is always the same. Is there a way for me to just create this code once – and not put it in every vc?

    [self.navigationItem setHidesBackButton:YES];

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonItemStyleBordered target:self action:@selector(backClicked)];

UIBarButtonItem *flexibleSpaceLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

UIBarButtonItem *storyBtnItem = [[UIBarButtonItem alloc]initWithTitle:@"Sto" style:UIBarButtonItemStyleBordered target:self action:@selector(toolbarControl:)];
storyBtnItem.tag = 1;
UIBarButtonItem *renderBtnItem = [[UIBarButtonItem alloc]initWithTitle:@"Ren" style:UIBarButtonItemStyleBordered target:self action:@selector(toolbarControl:)];
renderBtnItem.tag = 2;
UIBarButtonItem *amenBtnItem = [[UIBarButtonItem alloc]initWithTitle:@"Ame" style:UIBarButtonItemStyleBordered target:self action:@selector(toolbarControl:)];
amenBtnItem.tag = 3;
UIBarButtonItem *availBtnItem = [[UIBarButtonItem alloc]initWithTitle:@"Availability" style:UIBarButtonItemStyleBordered target:self action:@selector(toolbarControl:)];
availBtnItem.tag = 4;
UIBarButtonItem *eopBtnItem = [[UIBarButtonItem alloc]initWithTitle:@"Eq" style:UIBarButtonItemStyleBordered target:self action:@selector(toolbarControl:)];
eopBtnItem.tag = 5;
UIBarButtonItem *stkBtnItem = [[UIBarButtonItem alloc]initWithTitle:@"St" style:UIBarButtonItemStyleBordered target:self action:@selector(toolbarControl:)];
stkBtnItem.tag = 6;
UIBarButtonItem *movBtnItem = [[UIBarButtonItem alloc]initWithTitle:@"Fi" style:UIBarButtonItemStyleBordered target:self action:@selector(toolbarControl:)];
movBtnItem.tag = 7;
NSArray *items = [NSArray arrayWithObjects:flexibleSpaceLeft, stoBtnItem, reBtnItem, ameBtnItem, avaBtnItem,  eBtnItem, stBtnItem, mvBtnItem, nil];  
[self setToolbarItems:items];
[self.navigationController.toolbar setTintColor:[UIColor colorWithRed:79.0/255.0 green:145.0/255.0 blue:205.0/255.0 alpha:1.0]];
  • 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-26T18:06:50+00:00Added an answer on May 26, 2026 at 6:06 pm

    Just do vc.toolbarItems = self.toolbarItems (where vc is the view controller to be pushed) in the method where you are pushing the next view controller.

    eg:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        UIViewController *vc = [UIViewController new];
        vc.toolbarItems = self.toolbarItems
        [self.navigationController pushViewController:vc animated:YES];
        [vc release]; // if not using ARC
    }
    

    Also, you don’t need to do this in the -viewDidLoad method, setting the navigation items and toolbar items does not require the view to be loaded and can thus be done in your init or awakeFromNib method. If you do it in -viewDidLoad you are potentially setting the items multiple times.

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

Sidebar

Related Questions

Have an app that has listings - think classified ads - and each listing
have an app that finds your GPS location successfully, but I need to be
I have an app that needs to open a new window (in the same
I have an app written in C# that lies on a network share. When
I have a main view screen with navcontroller in my app with two UIbuttons.
Greetings! I have a working iPhone app (huzzah!) that uses a MainView.xib containing a
I have app that uses two threads: one thread for regular application work and
I created a navigation controller based app. The view that opens up below the
I have created an app in which I want to use the touchbegan method.
I have a SQLite DB containing tasks. Each task has a date, and there

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.