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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:13:04+00:00 2026-05-23T17:13:04+00:00

My application starts off with nothing but a UIWindow . I programmatically add a

  • 0

My application starts off with nothing but a UIWindow. I programmatically add a view controller to self.window in application:didFinishLaunchingWithOptions:.

myViewController = [[UIViewController alloc] init:...];
...

[self.window addSubview:myViewController.view];
[self.window makeKeyAndVisible];

At the same time i kick off a background process:

[NSThread detachNewThreadSelector:@selector(startupOperations) toTarget:self withObject:nil];

The startupOperations look something like this:

NSAutoreleasePool *threadPool = [[NSAutoreleasePool alloc] init];

// Load data
...

// When your done, call method on the main thread
[self performSelectorOnMainThread:@selector(showMainViewController) withObject:nil waitUntilDone:false];

// Release autorelease pool
[threadPool release];

showMainViewController removes myViewController, creates a UITabBarController and sets it as the window’s main view:

[self.myViewController.view removeFromSuperview];
self.myViewController = nil;

tabBarController = [[UITabBarController alloc] init];
...

[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];

Questions:

All the view controllers are returning YES for shouldAutorotateToInterfaceOrientation:. Rotation works fine for myViewController but as soon as the tabBarController is made visible, rotation stops working and interface appears in Portrait. What’s the reason behind this behavior?

Also, in iOS 4.x, UIWindow has rootViewController property. What’s the role of this property? The new templates use rootViewController instead of [self.window addSubview:...]. Why is that?

  • 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-23T17:13:04+00:00Added an answer on May 23, 2026 at 5:13 pm

    Pretty strange. I tried and simulate your “view flow” in a simple tab bar based project and autorotation effectively works after removing the initial controller and adding the tab bar controller’s view as a subview.

    The only condition I found where it did not work is when self.window did contain a second subview that I did not remove. Could you check at the moment when you execute

     [self.window addSubview:tabBarController.view];
    

    what is self.window.subview content?

    If that does not help, could you share in your question how you initialize the UITabBarController and UITabBar?

    As to your second question, as you say rootViewController is the root controller for all the views that belong to the window:

    The root view controller provides the content view of the window. Assigning a view controller to this property (either programmatically or using Interface Builder) installs the view controller’s view as the content view of the window. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.

    (Source)

    You can also use that, but take care of assigning it already in applicationDidFinishLaunching, otherwise, if you “manually” add a subview and later change this property, it will not remove the subview you explicitly added.

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

Sidebar

Related Questions

I've got a WPF application which starts off with a very small window. Something
It seems that when a WPF application starts, nothing has focus. This is really
I have two view controllers: MyParentViewController and MyChildViewController . The application starts with MyParent
Here is how my application works: The user starts off filling out a form
When a java based application starts to misbehave on a windows machine, you want
I'm getting an error when my application starts. It appears to be after it's
I've written a Autoit script that starts a GUI application, when the application starts
I am developing an application for PocketPC. When the application starts the custom function
I have couple resource DLLs that I currently load when application starts using following
I'm getting a System.NullReferenceException when my application starts up (after a small login screen)

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.