Josh Kahane Josh Kahane - 4 years ago 155
Objective-C Question

Container View Controller Status Bar iOS 7

I am having status bar issues. I have a

UIViewController
, this has a container view which embeds a
UITabBarController
inside that
UIViewController
.

When enabling the status bar in my app using
View controller-based status bar appearance
=
YES
in my
Info.plist
, it acts as normal, the root
UIViewController
displays the status bar as you expect.

However, it is causing the
UITabBarController
in the container view to push my view contents down by 20 pixels, leaving a gap at the top of my tabbar view for where it thinks the status bar should be.

But of course the status bar isn't shown there because its shown at the top of the screen where it normally is. So it is effectively just adding a gap in my container view.

Any help would be much appreciated, I have slaved over this issue and can't find a solution!

Thanks.

Answer Source

Turns out the topLayoutGuide was pushing my view down by 20 pixels for the status bar. Because it was expecting a status bar, the topLayoutGuide adds this 20 pixel space.

In my storyboard the topmost subview of my view controller had a constraint to fix it to the top of my view. This constraint was the view top equal to topLayoutGuide bottom.

This meant that when the topLayoutGuide added the 20 pixel space, my entire view was offset by that.

By changing the constraint to fix to the topLayoutGuide top instead, the space created is now just sitting underneath my normal subviews not causing any problems.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download