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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:16:02+00:00 2026-06-14T10:16:02+00:00

I have an application that creates a tabbarcontroller from the AppDelegate. I wanted to

  • 0

I have an application that creates a tabbarcontroller from the AppDelegate. I wanted to have a button added to the nav bar but was unable to. Eventually I managed to get hold of some working code, but I don’t really understand it.

The steps were:

  1. Confirm the AppDelegate to UINavigationControllerDelegate
  2. Set the rootNavigationController.delegate = self
  3. Override navigationController:willShowViewController:animated and tabBarController:didSelectViewController

I think I follow the tabBarController:didSelectViewController code, but am lost in what is happening with navigationController:willShowViewController:animated.

- (void) tabBarController: (UITabBarController*) tabBarController didSelectViewController: (UIViewController*) viewController
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
     self.tabBarController.navigationItem.title = viewController.navigationItem.title;
     self.tabBarController.navigationItem.rightBarButtonItems = viewController.navigationItem.rightBarButtonItems;
     self.tabBarController.navigationItem.leftBarButtonItems = viewController.navigationItem.leftBarButtonItems;
     }
  }



- (void) navigationController: (UINavigationController*) navigationController
   willShowViewController: (UIViewController*) viewController
                 animated: (BOOL) animated
    {
      if (viewController == tabBarController)
      {
        UIViewController* tabViewController = tabBarController.selectedViewController;
    SEL willShowSel = @selector(navigationController:willShowViewController:animated:);

      if ([tabViewController respondsToSelector: willShowSel])
      {
        UIViewController<UINavigationControllerDelegate>* vc =
            (UIViewController<UINavigationControllerDelegate>*) tabViewController;
        [vc navigationController: navigationController willShowViewController: vc animated: animated];
      }
  }
  • 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-14T10:16:03+00:00Added an answer on June 14, 2026 at 10:16 am

    This code is likely dealing with problems that occur using a UITabBarController within a UINavigationController. The UITabBarController documentation states that it needs to be the root view controller (i.e. NOT within a UINavigationController) and using it in other ways can cause problems.

    What the code appears to be doing is capturing the event normally passed to viewController, checking if it is a UITabBarController and if it is, then it checks whether the visible view in the UITabBarController responds to this method, and if it does then it passes the method (selector) call on to that view.

    If it is possible, I’d recommend pulling the UITabBarController out from being embedded in the UINavigationController. Might take a bit of work, but will make your code compliant. (And remove need for navigationController:willShowViewController:animated:

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

Sidebar

Related Questions

I have created an application that creates bar graph based on inputs read from
I have an application that creates invalid Directories... e.g. c:\Program Files\somedirectory. - the period
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have a .Net application that dynamically creates a small HTML page and pops
Today we have a windows application that, using an OCX, creates a web page
I have an application that creates a configuration file and a log file. I
I have an application that creates a playlist of videos and returns them in
I have an application that creates a notification with sound when a specific text
I have an application that creates a separate database (SQL Server 2008) for each
I have a web application that creates XML feeds on the fly, depending on

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.