Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent UINavigationBar from covering top of view in iOS 7?

After updating to Xcode 5, the navigation bars in all of my app's views have shifted down. Here are some screenshots, the first showing everything in the view as it's pulled down, and the second showing all of it untouched. The search bar should begin where the navigation bar.

All ContentAll Content on Idle

Anyone know how I can fix this?

edit: i have tried this previously recommendation:

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

But it yields very odd results.

Solution Attempt

This may be because I have a "slide menu" under this view controller that is appearing due to the transparency of the navigation bar.

like image 452
Sam D20 Avatar asked Sep 23 '13 07:09

Sam D20


People also ask

What is a navigation controller iOS?

Overview. A navigation controller is a container view controller that manages one or more child view controllers in a navigation interface. In this type of interface, only one child view controller is visible at a time.

What is the navigation controller?

NavController manages app navigation within a NavHost . Apps will generally obtain a controller directly from a host, or by using one of the utility methods on the Navigation class rather than create a controller directly. Navigation flows and destinations are determined by the navigation graph owned by the controller.

Is UINavigationController a UIViewController?

A UINavigationController does a lot of this tedious work for you. As mentioned, it contains a stack of UIViewControllers. It will create a navigation bar at the top that will allow you to easily go back up the hierarchy of view controllers.


1 Answers

Set the navigation bar's translucent property to NO:

self.navigationController.navigationBar.translucent = NO; 

This will fix the view from being framed underneath the navigation bar and status bar.

If you have to show and hide the navigation bar, then use

 if ([self respondsToSelector:@selector(edgesForExtendedLayout)])     self.edgesForExtendedLayout = UIRectEdgeNone;   // iOS 7 specific 

in your viewDidLoad method.

like image 117
Deepesh Avatar answered Oct 03 '22 00:10

Deepesh