DropMenu icon indicating copy to clipboard operation
DropMenu copied to clipboard

The NavigationBar is covering the top of the view

Open egabor opened this issue 10 years ago • 2 comments

I had this issue when I added some content to the view.

Maybe similar to this: http://stackoverflow.com/questions/18953509/how-to-prevent-uinavigationbar-from-covering-top-of-view-in-ios-7 But in iOS 8.

image1

egabor avatar Aug 15 '15 07:08 egabor

@egabor Did you manage to fix this issue? I experience the same and totally broke my head trying to fix it...

popovae avatar Dec 06 '15 09:12 popovae

This happens if you extend the edges beneath the navigation bar. To remedy this I used a hack as shown below. This is a temporary solution until someone finds a better way of doing things

In ViewController.m do the following

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    if (CGRectGetMinY(self.view.frame) < 64)
    {
        self.view.frame = CGRectOffset(self.view.frame, 0.0, 20.0f);
    }

}

If you are keen, you would realise that this issue never happens when the app starts, thats because on startup, the viewcontroller is initialised taking the status bar into account.

Therefore in the above solution, we check to make sure the status bar has been accounted for, Navigationbar.height(44) + statusBar.height(20) = 64, anything less assume no status bar.

On subsequent initialisations, the viewcontroller is halfway down the screen with only a navigation bar, this does not take into account the status bar.

A good solution would include detecting when the status bar is sitting atop the viewcontroller and refreshing re-layout subviews.

edwinbosire avatar Dec 09 '15 13:12 edwinbosire