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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:33:46+00:00 2026-06-05T03:33:46+00:00

I want to catch the event when someone switches between tabs. I have the

  • 0

I want to catch the event when someone switches between tabs. I have the following two function in my appdelegate file:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UITabBarController * uitbc = [storyboard instantiateViewControllerWithIdentifier:@"tabbarcontroller"];
    uitbc.delegate = self;
    [self.window addSubview:uitbc.view];

    return YES;
}


- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    NSLog(@"switching");
}

But the NSLog(@"switching"); never fires. The xcode issues a warning for the line uitbc.delegate = self; saying “Passing appdelegate const__strong to parameter of incompatible type id”.

What am I doing wrong? I’m just following the accepted answer found here, except i’m instantiating my tabbarcontroller form story board:

how to get the event that switch tab menu on iphone

Update
Based on skram’s suggestion, I wrote this for my appdelegate but the NSLOG(Switching) still doesn’t fire:

@interface johnAppDelegate : UIResponder <UITabBarControllerDelegate>

I also updated my didFinishLauchingWithOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
tabBarController = self.window.rootViewController.tabBarController;
tabBarController.delegate = self;
[window addSubview:tabBarController.view];
}

Good thing is that nothing crashes. I also no longer et the warning about incompatible types. But still, didSelectViewController doesn’t fire.

  • 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-05T03:33:47+00:00Added an answer on June 5, 2026 at 3:33 am

    in my appdelegate.h file, I changed the line

    @interface wscAppDelegate : UIResponder <UIApplicationDelegate>
    

    to

    @interface wscAppDelegate : UIResponder <UIApplicationDelegate,UITabBarControllerDelegate>
    

    Then in my CustomTabBarController in the viewDidLoad function i added these lines:

    wscAppDelegate *appDelegate = (wscAppDelegate *)[[UIApplication sharedApplication] delegate];
    self.delegate = appDelegate;
    

    Then in appdelegate.m file, I added this function

    - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
    {
    
    NSLog(@"hooray this works");
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a web application. I want to catch the keypress event with
-I want to raise an event whenever method showmessage is called.I want to catch
I want to have a 'catch all' route which runs when none of the
I want my app to catch downloads of a particular kind of file. Here's
i have this code in QT and all i want to to catch the
I want to catch an event when the user finishes editing EditText. How can
I have question for you ... I have UITableView and I want to catch
I want to catch the event that user clicks and holds mouse on a
Can someone possibly help me with this? I want to observe a file to
I have two forms and I am trying to capture an event generated from

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.