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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:45:46+00:00 2026-05-18T21:45:46+00:00

My iphone application is showing strange behavior when rotating: a gap appears between the

  • 0

My iphone application is showing strange behavior when rotating: a gap appears between the navigation title and content view inside a tab bar view (details on how to reproduce are below). I’ve created a tiny test case that exhibits the same problem: a custom root UIViewController, which creates and displays a UITabBarController programmatically, which has two tabs: 1) plain UIViewController, and 2) UINavigationController created programmatically with a single plain UIViewController content view.

The complete code for the application is in the root controller’s viewDidLoad (every “*VC” class is a totally vanilla UIViewController subclass with XIB for user interface from XCode, with only the view background color changed to clearly identify each view, nothing else).

Here’s the viewDidLoad code, and the shouldAutorotateToInterfaceOrientation code, this code is the entire application basically:

- (void)viewDidLoad {
    [super viewDidLoad];

    FirstVC *fvc = [[FirstVC alloc] initWithNibName:@"FirstVC" bundle:nil];
    NavContentsVC *ncvc = [[NavContentsVC alloc] initWithNibName:@"NavContentsVC" bundle:nil];
    UINavigationController *svc = [[UINavigationController alloc] initWithRootViewController:ncvc];

    NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:2];
    [localControllersArray addObject:fvc];
    [localControllersArray addObject:svc];

    fvc.title = @"FirstVC-Title";
    ncvc.title = @"NavContents-Title";

    UITabBarController *tbc = [[UITabBarController alloc] init];
    tbc.view.frame = CGRectMake(0, 0, 320, 460);
    [tbc setViewControllers:localControllersArray];
    [self.view addSubview:tbc.view];

    [localControllersArray release];
    [ncvc release];
    [svc release];
    [fvc release];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    return YES;
}

Here’s how to reproduce the problem:

1) start application

2) rotate device (happens in simulator, too) to landscape (UITabBar properly rotates)

3) click on tab 2

4) rotate device to portrait — notice gap of root view controller’s background color of about 10 pixels high beneath the Navigation title bar and the Navigation content view.

5) click tab 1

6) click tab 2

And the gap is gone! From my real application, I see that the gap remains during all VC push and pops while the NavigationController tab is active. Switching away to a different tab and back to the Nav tab clears up the gap.

What am I doing wrong? I’m running on SDK 3.1.3, this happens both on the simulator and on the device. Except for this particular sequence, everything seems to work fine. Help!

  • 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-18T21:45:47+00:00Added an answer on May 18, 2026 at 9:45 pm

    This problem occurs when you nest a UINavigationController within another UIViewController (in this case a UITabBarController). If you had the UINavigationController as the root view controller, then this problem wouldn’t occur.

    One solution may be to go in and alter the frame of the navigation bar (set the y origin from 0 to 20), but the documentation states explicitly not to do this. So to me, this is an indication that it isn’t considered good UI to nest a UINavigationController – you shouldn’t be doing it.

    Please let me know what you think – thanks. 🙂

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

Sidebar

Related Questions

No related questions found

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.