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

  • Home
  • SEARCH
  • 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 6716453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:44:08+00:00 2026-05-26T08:44:08+00:00

I have a standard UIViewController which works a charm. However, I want to add

  • 0

I have a standard UIViewController which works a charm. However, I want to add a UINavigationController on top of this as a subview, add and remove it at will. However, it seems you can’t simply add another controller onto a current controller as a subview. So how do I go about this?

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-26T08:44:08+00:00Added an answer on May 26, 2026 at 8:44 am

    Here’s some code that creates a new view in a navigation controller and shows it “on top” (presents it modally).

    There’s a few key things here:

    If you present a nav controller modally, you need to set it’s left & right buttons (if you need to) before you initWithRootController and presentModally

    Even if you’re current view is in a navController, if you present it modally, it needs to be wrapped in a UINavigationcontroller (there’s some SO posts covering that)

    UINavigationController with presentModalViewController

    MyView *myView = [[MyView alloc] initWithNibName:@"MyView" bundle:nil];
    
    UIBarButtonItem *cancelBtn = [[UIBarButtonImageItem alloc] init...  
    
    UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] init...
    
    [[myView navigationItem] setLeftBarButtonItem:cancelBtn];
    [[myView navigationItem] setRightBarButtonItem:doneBtn];  
    [cancelBtn release];    
    [doneBtn release];
    
    // Edit purchase in full modal view.
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myView];
    
    [[self navigationController] presentModalViewController:navController animated:YES];
    

    Then, from within the view you just presented modally, you can dismiss it. For example, in this code the save and cancel buttons added above are associated with these IBAction methods on the view controller you presentedModally:

    - (IBAction)cancel:(id)sender
    {
        NSLog(@"cancel");
        [self dismissModalViewControllerAnimated:YES];
    }
    
    - (IBAction)save:(id)save
    {
        NSLog(@"done");
        // do work here
        [self dismissModalViewControllerAnimated:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have standard .net 2.0 gridview control from which i want to get row
I have an app which starts with a root UINavigationController . This controller then
In my mainWindow.xib, I have this setup. 1) UINavigationController containing several viewControllers. 2) UIViewController
I have standard source code package under Linux which requires to run ./configure make
Is it possible to have standard war deployment, which can be deployed on tomcat
I have a mobile site running with jQuery Mobile. I want to have standard
I have a standard table: I want to use jQuery to reformat the table,
I have a standard form array in PHP like this. I need to account
I have standard class library infrastructure assembly which i reference in my main application.
I have Standard version of eclipse Galileo. Now I want to develop enterprise applications

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.