0

I have a problem with navigation and status bars in iOS 8. Status bar overlaps navigation bar. It is not a new problem, but my case is more specific.

I'm using RESideMenu in my app and the problem shows up when I use navigation controller as the content view. I saw a dozen of solutions with changing frames of the view or screen. Such solution doesn't seem to be right, because the app after going to background and back to foreground is changing its navigation bar to right size and position. I would like to know what causes this behavior.

I looked at various frames and sizes to examine which parameters change after switch.

These params are before switch:

View frame: (0.0,0.0,320.0,568.0)
View bounds: (0.0,0.0,320.0,568.0)
View margins: top: 0.0, left: 0.0, bottom: 0.0, right: 0.0
VC Preferred size: (0.0,0.0)
NavBar rect: (0.0,0.0,320.0,44.0)
NavBar bounds: (0.0,0.0,320.0,44.0)
NavBar margins: top: 0.0, left: 16.0, bottom: 0.0, right: 16.0

and after switch:

View frame: (0.0,0.0,320.0,568.0)
View bounds: (0.0,0.0,320.0,568.0)
View margins: top: 0.0, left: 16.0, bottom: 0.0, right: 16.0
VC Preferred size: (0.0,0.0)
NavBar rect: (0.0,20.0,320.0,44.0)
NavBar bounds: (0.0,0.0,320.0,44.0)
NavBar margins: top: 0.0, left: 16.0, bottom: 0.0, right: 16.0

As you can see the NavBar rect has changed its Y-Position from 0.0 to 20.0. If I force those params at init point it wouldn't help. (It moves the navigation bar but its not the right way, after app-switch it would be even more messy). Interesting fact is, that the margins of View change after app-switch. Why does it change those left-right values anyway?

Here my screenshots:

Before switch:

http://postimg.org/image/ddqlcm5xl/

After switch:

http://postimg.org/image/q4exx9zql/

I tried to hide or show status bar manually in code and per Info.plist. It didn't work neither.

I want navigation bar and status bar to look like in second screenshot without having to switch the app back and forth.

Any ideas?

batonPiotr
  • 13
  • 4

1 Answers1

0

Try this code,

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
    self.edgesForExtendedLayout=UIRectEdgeNone;
}

Paste it in view did load. Hope this helps.

Saif
  • 2,678
  • 2
  • 22
  • 38