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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:11:32+00:00 2026-05-25T11:11:32+00:00

I need some help on how to create a Navigation Controller that loads its

  • 0

I need some help on how to create a Navigation Controller that loads its Root View Controller to a Main View Controller. Then, I want to have that Navigation Controller two selector buttons (leftBarButtonItem and rightBarButtonItem) that will take the user to 2 custom View Controllers (AboutViewController and SettingsViewController).

I was able to do this successfully but instead, I created the 2 view controllers inside the MainWindow.xib with all codes inside AppDelegate.h and AppDelegate.m. This is obviously not a good practice especially when you have a lot of custom view controllers.

Thanks.

  • 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-25T11:11:33+00:00Added an answer on May 25, 2026 at 11:11 am

    You are right that it isn’t good practice to create your view controllers in the AppDelegate. Instead, you should create a separate ViewController for each view. In the implementation file for your rootViewController, create methods to push the separate view controllers that you want to show when the buttons are pressed. Something like this would work:

    - (void)showAboutView
    {
        AboutViewController *aboutViewController = [[AboutViewController alloc] init];
        [self.navigationController pushViewController:aboutViewController animated:YES];
    }
    
    - (void)showSettingsView
    {
        SettingsViewController *settingsViewController = [[SettingsViewController alloc] init];
        [self.navigationController pushViewController:settingsViewController animated:YES];
    }
    

    Then, include those methods in the selector field for your buttons. Like this:

    UIBarButtonItem *aboutBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(showAboutView)];
    
    [[self navigationItem] setRightBarButtonItem:aboutBarButtonItem];
    

    This should take care of pushing your view. The navigationController will automatically show a button to ‘go back’.

    In the AppDelegate, you would create the navigationController and tell it what view will be the rootViewController, like this:

    ViewController1 *vc1 = [[ViewController1 alloc] init];
    mainNavigationController = [[UINavigationController alloc] initWithRootViewController:vc1];
    

    Hope this helps!

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

Sidebar

Related Questions

I need some help. I want to create one tournament. Let's say I have
I need some help. I want to create a for loop that creates n
Need some help about with Memcache. I have created a class and want to
I need some help with a query. I have this simple table: CREATE TABLE
A need some help, I have a TextBlock that contains a string like this
I need some help to create jquery script :) I have some of link
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
Need some help to solve this. I have a gridview and inside the gridview
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
Need some help assigning a mouseover event to display some icons that start out

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.