Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status Bar overlaps Navigation Bar when bring back app from background #39

Open
kissfro opened this issue Dec 29, 2011 · 2 comments
Open

Comments

@kissfro
Copy link

kissfro commented Dec 29, 2011

Hi, first off thanks for this code it works great. I noticed one thing though when you're looking at a photo (KTPhotoView). If the bars have disappeared, and you click the home button to exit the app, when you reenter the app, and tap the screen to make the bars reappear, the statusbar will have overlapped the navigation bar.

@kissfro
Copy link
Author

kissfro commented Dec 31, 2011

I managed to fix this problem. I had to rewrite the toggle:hide method using the animateWithDuration block instead of UIView beginAnimation. Reason I did this was to take advantage of the "complete" block, because after you animate your bars to hide, you have to make the navigation bar disappear as well (if you don't do it after the animation has completed, it will disappear before the animation takes place). The reason you have to do this is so when the bars reappear, you have to reshow the navigation bar AFTER you show the status bar. The reason for this is for some odd reason (maybe a bug) the navigation bar will put itself at the top of the screen (where the statusbar should be) because it thinks it isn't there. if you reshow the navbar after the statusbar, it sets itself correctly. Anyway, here is the code (I have a tabbar instead of a toolbar):

-(void) toggleBars:(BOOL)hide
{
self.isHidden = hide;

if (hide)
{
    [UIView animateWithDuration:.4 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^
    {
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
        [[[self navigationController] navigationBar] setAlpha: 0.0];
        [[[self tabBarController] tabBar] setAlpha: 0.0];
    }
    completion:^(BOOL finished)
    {
        [[self navigationController] setNavigationBarHidden:YES animated: NO];
    }];
}
else
{
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];
    [[self navigationController] setNavigationBarHidden:NO animated: NO];
    [[[self navigationController] navigationBar] setAlpha: 1.0];
    [[[self tabBarController] tabBar] setAlpha: .625];
    [self startDisplayTimer];
}

}

@kissfro
Copy link
Author

kissfro commented Dec 31, 2011

Actually, there is a bug in the above code. If you double tap while the bars are showing, the nav bar will disappear when it shouldn't. Honestly the solution I'm just going with at this point is to move the navigation bars frame down 20 pixels (y + 20) after you set the status bar to reappear. It's not clean, but it gets the job done until further notice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant