Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation Controller is rendered over the view I navigated to

Have you guys stumbled up on this issue ?

Basically in iOS 7 Navigation Controller is rendered over the sub-view I navigated to.

In iOS 6 view I navigate to is enclosed between navigation bar and footer. In iOS 7 it looks like sub-view is rendered full-screen, under navigation bar and footer. As result user don't see it.

Here is how I navigate to subview

BRSMyListSubViewController *tagsInfoVC = [[BRSMyListSubViewController alloc] initWithCheckinsList:self.checkinsList
                                                                                selectedTag:[self tagByIndexPath:indexPath]];

[self.navigationController pushViewController:tagsInfoVC animated:YES];

Here is how I initialize it in viewDidLoad

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Settings" style:UIBarButtonItemStyleBordered target:self action:@selector(settings:)];

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStyleBordered target:self action:@selector(logout:)];

For what it's worth I should also mention that sub-view is defined in XIB using Autolayout. Here is source of my XIB: http://pastebin.com/6RR0zYu4

And finally here is how it looks in iOS 6

enter image description here

And in iOS 7

enter image description here

Any thoughts ?

like image 968
expert Avatar asked Aug 29 '13 04:08

expert


People also ask

What is a navigation view controller?

Introduction to Navigation Controllers. A UINavigationController is a view controller subclass that makes navigation between multiple view controllers easier. In addition to easier navigation, a navigation controller also has a lot of built-in functionality that we'll explore in this section.

How do I add a view controller to my navigation controller?

Step 1: Embed root view controller inside a navigation controller. In your storyboard, select the initial view controller in your hierarchy. With this view controller selected, choose the menu item Editor -> Embed In -> Navigation Controller .

What is the use of navigation controller?

The navigation controller manages the navigation bar at the top of the interface and an optional toolbar at the bottom of the interface. The navigation bar is always present and is managed by the navigation controller itself, which updates the navigation bar using the content provided by its child view controllers.


1 Answers

Well, I figured it out.

In your sub-view (BRSMyListSubViewController in my case), in viewDidLoad, you need to set one of these two

self.edgesForExtendedLayout = UIRectEdgeNone;
self.automaticallyAdjustsScrollViewInsets = NO;

OR

self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = YES;

Interestingly enough in root view controller these value are set to default UIRectEdgeAll, NO and YES respectively but its tableView is NOT under navbar and footer.

I don't know why it's so illogical.

It's also strange that edgesForExtendedLayout has to be mixed with one of two other properties even though it's clearly responsible for the behavior.

PS. For those who wants to run it on iOS 6. Surruound the code with if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)

like image 131
expert Avatar answered Oct 22 '22 18:10

expert