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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:58:11+00:00 2026-05-20T04:58:11+00:00

1. Step: Create a new UIViewController: – Xcode -> New File… -> Cocoa Touch

  • 0

1. Step: Create a new UIViewController:
– Xcode -> New File… -> Cocoa Touch Class -> UIViewController
– Name: MyViewController

2. Step: Drag and drop a “Navigation Controller” (UINavigationController) from the Library to MyViewController.xib

alt text

3.Step: I’m sure, I have to do something to connect the Navigation Controller correctly, isn’t it?

4.Step: Try to start the new View Controller as a modal dialog:

MyViewController *myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
NSLog(@"navContr: %@", myViewController.navigationController);
[self.navigationController presentModalViewController: myViewController animated:YES]; 

Result: “navContr: nil”

5.Step: You can see the new modal view (MyViewController), but there’s no NavigationController and no UINavigationBar.

Thank you very much for your help!


UPDATE 1:

6.Step: I set a new UIViewController (ViewNavi2) as “Root View Controller”:
alt text

7.Step: I define a IBOutlet UINavigationController *navigationController in the class MyViewController and configure the xib: Navigation Controller -> Connections -> Referencing Outlets

But my Navigation Controller is still nil 🙁

MyViewController *myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
NSLog(@"navContr: %@", myViewController.navigationController);
// -> "navContr: nil"
  • 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-20T04:58:12+00:00Added an answer on May 20, 2026 at 4:58 am

    I also wanted to include the navigation controller in the NIB file, but all that the Apple documentation said was that it is “not optimal” without actually explaining how to do it. I wanted my main tabbed window to call up a modal window containing the typical navigation controls without defining the navigation controller programmatically. I’ll share how I did it.

    Your code was very similar to mine, as I also defined an IBOutlet UINavigationController *navigationController in MyViewController. From Interface Builder, I simply defined my view in the root view controller and set the File’s Owner->view to that view definition.

    And similarly to your code, I did the following in my parent window:

    MyViewController *myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
    [self presentModalViewController:myViewController animated:YES];
    

    (I am calling presentModelViewController on self, I don’t know why you had self.navigationController.) When I tested this, the result was that my view was loaded from the NIB file, but the navigation bar was missing. One more line of code in MyViewController fixed this:

    - (void)viewDidLoad {
        [super viewDidLoad];
    
        [self setView:myNavigationController.view];
    
    }
    

    All I am doing here, is setting MyViewController’s view to point to myNavigationController.view, which contains everything that was defined in the NIB file, including the navigation controller.

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

Sidebar

Related Questions

I would like to to create a 2-step file uploader: Open dialog. Select one
Possible Duplicate: Class methods which create new instances How would you declare a constructor
I have an XML file: <tasks> <task name=task-12> <step>Open folder</step> <step nextTask=task-14>Delete contents.</step> </task>
I used In App Purchase and i follow all step to create In App
How to create in-app step by step instructions? Like this ( first boot android
I create a asp.net page and test the code in debug mode step by
I am looking for the best solution to create a 3 step sign up
For strongly-typed & type-safe solution, I have to do the following step. Create some
On this page Step 1: Create a Facebook App To create a Facebook app,
I an trying to create new stored procedures. Below is the code segment for

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.