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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:02:35+00:00 2026-06-09T11:02:35+00:00

II wanted to add a UIBarButton to my UINavigationController. I did that with the

  • 0

II wanted to add a UIBarButton to my UINavigationController. I did that with the help of following code,

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    UIViewController *rootController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];

    self.navigationController = [[UINavigationController alloc] initWithRootViewController:rootController];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window addSubview:navigationController.view];
    [self.window makeKeyAndVisible];
    return YES;
}


- (void)viewDidLoad
{
    [super viewDidLoad];

    UIBarButtonItem *addInfoButton = [[UIBarButtonItem alloc] initWithTitle:@"Add Info" style:UIBarButtonItemStylePlain target:self action:@selector(addCustomerInfo)];
    self.navigationItem.rightBarButtonItem = addInfoButton;
}

-(void) addCustomerInfo
{
    AddInfoViewController *addVC = [[AddInfoViewController alloc] initWithNibName:@"AddInfoViewController" bundle:nil];

    [addVC setModalTransitionStyle:UIModalTransitionStyleCoverVertical];

    [self presentModalViewController:addVC animated:YES];
}

Should I declare “-(void) addCustomerInfo” in .h file? I already tried that but no luck.

The code still throws the exeption,

2012-08-06 04:16:22.200 TableView[5698:f803] -[RootViewController addCustomerInfo]: unrecognized selector sent to instance 0x6c662b0
2012-08-06 04:16:22.202 TableView[5698:f803] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[RootViewController addCustomerInfo]: unrecognized selector sent to instance 0x6c662b0’

  • 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-09T11:02:37+00:00Added an answer on June 9, 2026 at 11:02 am

    The code for your class is correct. You need to change your App Delegate

    I suggest creating a property in your App Delegate to store your navigation controller –@property (strong, nonatomic) UINavigationController *navController; – Don’t forget to synthesize it.
    Then, when you create your Navigation controller, set it to your property – self.navController = [[UINavigationController alloc] init];

    This will guarantee your NavigationController is properly retained and that it can be accessed correctly by other classes in your application.

    Below some sample code that might make it clearer:

    First the AppDelegate header file:

    //AppDelegate.h
    #import <UIKit/UIKit.h>
    
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    {
        UINavigationController *navController;
    }
    @property (strong, nonatomic) UIWindow *window;
    @property (strong, nonatomic) UINavigationController *navController;    
    @end
    

    And the implementation file:

    //  AppDelegate.m
    #import "AppDelegate.h"
    @implementation AppDelegate
    @synthesize window = _window;
    @synthesize navController;
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        self.navController = [[UINavigationController alloc] init];    
        UIViewController *myVC= [[myVC alloc]     init];
        [self.navController pushViewController:myVC animated:NO];
        [self.window addSubview:navController.view];
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wanted to add an alias for one of the charsets that PayPal may use
If I wanted to add two natural numbers together that are more then 150
I have a project that requires lots of image processing and wanted to add
just wanted to add this Color Picker ( http://code.google.com/p/devmil-android-color-picker/source/browse/ ) to my app and
I wanted to add a .jsp file to an ear that is deployed at
I wanted to add an Xcode project to an existing repository using the following:
I have an iPhone application which I wanted to add URL schemes to. The
I wanted to add a table and a foreign key to that table. Initially
Update: 24 Mar 2011: Just wanted to add that I've had a look at
I've taken over some old legacy JSP code and wanted to add some mail

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.