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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:28:27+00:00 2026-05-21T17:28:27+00:00

Through this question I would like to know if I understand well the notion

  • 0

Through this question I would like to know if I understand well the notion of Root View Controller.

In iOS application, the Root View Controller (RVC) is the controller whose view gets added to the UIWindow application at startup, isn’t true?

[window addSubview:rvcController.View];
[window makeKeyAndVisible];

Now, an UIWindow has also a rootViewController property. When running the previous snippet of code, does that property gets populated with the rvcController or do I have to set it explicitly?

Then, in a UINavigationController it is possible to set a RVC that is different from the previous RVC set for the entry point.

In this case, the first time I add a controller to the navigationController stack (pushing a new controller on it), does the framework set that controller as the RVC for the navigationController or do I have to set it explicitly through initWithRootViewController method?

  • 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-21T17:28:27+00:00Added an answer on May 21, 2026 at 5:28 pm

    Ya.. when I began iPhone dev.. the rootViewController thing threw me for a loop too. But it’s really straight forward.

    when the app starts, I create a UIWindow object in my app delegate class. Also, in that class, I have a property of type UIWindow called window;

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  
    
        UIWindow *w = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
        self.window=w;
        [w release];
        // other code here...
    }
    

    I then create a UIViewController whose view will be the first view in the window hierarchy, this could be called the “root view controller”.

    The confusing part is…that often we create a UINavigationController as the “root view controller” and that navigation controller has an init method that asks for a “RootViewController”, which is the first viewcontroller it will place on its stack.

    So, the window gets a “root view controller”, which is the UINavigationController, which also has a RootViewController, which is the first view controller you want to show.

    once you sort that out, its all makes sense.. I think 🙂

    here is some code that does it all.. (taken from a project I have open in front of me)

    //called with the app first loads and runs.. does not fire on restarts while that app was in memory
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
    
        //create the base window.. an ios thing
        UIWindow *w = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
        self.window=w;
        [w release];
    
        // this is the home page from the user's perspective
        //the UINavController wraps around the MainViewController, or better said, the MainViewController is the root view controller
        MainViewController *vc = [[MainViewController alloc]init];
    
        UINavigationController *nc = [[UINavigationController alloc]initWithRootViewController:vc];
        self.navigationController=nc;  // I have a property on the app delegate that references the root view controller, which is my navigation controller.
    
        [nc release];
        [vc release];
    
        //show them
        [self.window addSubview:nc.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

Reading through this question on multi-threaded javascript, I was wondering if there would be
This is probably an easy question, but I'd like to iterate through the tags
I know this is an oft-asked question/problem. I've looked through a bunch of Q&A
Yesterday while going through this question, I found a curious case of passing and
Edit This question has gone through a few iterations by now, so feel free
After having this question answered through a link to an external site , I
I've checked through other questions and surprisingly this question doesn't seem to have been
I have gone through this and this , but the question I am asking
Okay, this question comes through a friend so it might be lost in translation...
This is probably a basic question, better explained through code: public void checkStatus {

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.