14

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 ?

2 Answers 2

37

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)

5
  • Thank you for putting the answer, it really helped me.
    – titicaca
    Sep 12, 2013 at 6:11
  • It works only for iOS7 if you run the application in iOS6 running device it will give exception as are iOS7 SDK properties
    – Usman Awan
    Sep 25, 2013 at 8:26
  • 1
    @UsmanAwan Of course it would give exception. These properties didn't exist in 6 :) You need to check it with selector. I updated this answer.
    – expert
    Sep 25, 2013 at 16:55
  • This seems to impact other views that are loaded after this view, is there a way to avoid that?
    – pfrank
    Jan 14, 2014 at 7:05
  • 2
    @ruslan It is better to do a method check then a system version check. if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) just incase the system version and foundation version are not in line.
    – rckoenes
    Jan 28, 2014 at 11:25
4

If you don't mind having an opaque navigation bar, then the simplest solution could be to do this in the view controller that creates your navigation controller:

self.navigationController.navigationBar.translucent = NO;

The positioning of the frame will then adopt the same behavior as iOS6, magically!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.