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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:49:52+00:00 2026-05-24T11:49:52+00:00

I have a navigation-based application where it is possible for the user to hide

  • 0

I have a navigation-based application where it is possible for the user to hide the status bar. This is remembered in a defaults setting.

It is mostly working, with the one exception that if the app is loaded (from scratch, not returned to after going back to the home screen) when the status bar should be visible, when it is toggled to invisible, the navigation bar does not move up to fill the screen. Toggling the setting after that moves the navigation bar up and down correctly, but still with the extra status bar-sized gap between the navigation bar and the top of the screen, or the status bar. If I return to the home screen and re-enter the application, this corrects itself. I therefore assume there is some method being called on the uinavigationcontroller upon return to the application that I need to call after my toggling of the status bar?

I have tried (I think) all combinations of the wantsfullscreenlayout property, I was setting it in the method below but it made no difference, so I ended up setting it (on the navigationcontroller) to NO in the nib.

Here is the code which toggles the status bar. This is in my application delegate, which has the navigationcontroller and window set up as outlets as per the template application.

if ([UIApplication sharedApplication].statusBarHidden != hideStatusBar)
{
    [[UIApplication sharedApplication] setStatusBarHidden:hideStatusBar withAnimation:UIStatusBarAnimationSlide];
    [UIView animateWithDuration:0.25 animations:^{
        window.frame = [[UIScreen mainScreen] applicationFrame];
    }];
}
else
{
    window.frame = [[UIScreen mainScreen] applicationFrame];
}

Thanks for your help.

UPDATE

It seems, via NSLogging, that the problem lies in the frame of the UINavigationBar. So I have added the following code, which works and animates but I am not happy with! I don’t feel this can be the “correct” way to do this. In most cases the extra code does nothing since the frame is already at (0,0), but in the one situation where it is incorrect, this gives the right result.

[navigationController.view setNeedsLayout];
CGRect navBarFrame;
UINavigationBar *navBar = nil;
for (UIView *subView in navigationController.view.subviews)
{
    if ([subView isMemberOfClass:[UINavigationBar class]])
    {
        navBar = (UINavigationBar *)subView;
        navBarFrame = navBar.frame;
        navBarFrame.origin = CGPointMake(0,0);
        break;
    }
}

if ([UIApplication sharedApplication].statusBarHidden != hideStatusBar)
{
    [[UIApplication sharedApplication] setStatusBarHidden:hideStatusBar withAnimation:UIStatusBarAnimationSlide];
    [UIView animateWithDuration:0.25 animations:^{
        window.frame = [[UIScreen mainScreen] applicationFrame];
        navBar.frame = navBarFrame;
    }];
}
else
{
    window.frame = [[UIScreen mainScreen] applicationFrame];
}
  • 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-24T11:49:52+00:00Added an answer on May 24, 2026 at 11:49 am

    the problem lies in the frame of the UINavigationBar. So I have added the following code, which works and animates but I am not happy with! I don’t feel this can be the “correct” way to do this. In most cases the extra code does nothing since the frame is already at (0,0), but in the one situation where it is incorrect, this gives the right result.

    [navigationController.view setNeedsLayout];
    CGRect navBarFrame;
    UINavigationBar *navBar = nil;
    for (UIView *subView in navigationController.view.subviews)
    {
        if ([subView isMemberOfClass:[UINavigationBar class]])
        {
        navBar = (UINavigationBar *)subView;
        navBarFrame = navBar.frame;
        navBarFrame.origin = CGPointMake(0,0);
        break;
        }
    }
    
    if ([UIApplication sharedApplication].statusBarHidden != hideStatusBar)
    {
        [[UIApplication sharedApplication] setStatusBarHidden:hideStatusBar withAnimation:UIStatusBarAnimationSlide];
        [UIView animateWithDuration:0.25 animations:^{
        window.frame = [[UIScreen mainScreen] applicationFrame];
        navBar.frame = navBarFrame;
        }];
    }
    else
    {
        window.frame = [[UIScreen mainScreen] applicationFrame];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIView with a navigation bar. How can I hide the navigation
I have a navigation-based application with 2 UIViewControllers (controller-2 is pushed onto controller-1 when
Hey. I have a Navigation-controller-based application with a number of Viewcontrollers in it which
I have a page which work like a navigation and a iframe in this
I have a web application that functions as a dashboard, allowing a user to
I'm currently trying to create a navigation based application, pushing views to change the
I'm curious if it's possible to create an application according to window-based pattern, add
I have a navigation based iPhone app. Normally you start on the RootViewController, there
I am using a Data.plist file to populate my UITableView/Navigation-based Application with data. it
I have a tabbar based application. The tabbarcontroller is on the top of the

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.