5
votes

I started a project with Xcode 4, and today I updated my Xcode to 5. Running the same project in iOS7 simulator revealed some interesting (also frustrating) issues.

So my app has a sidebar that the user can tap on, and based on which button they tap on, I would instantiate a new VC using this code

YMGeneralInfoTableViewController *generalInfoTableVC = [self.storyboard instantiateViewControllerWithIdentifier:@"generalInfoTableVC"];

Then push this new VC onto the nav stack with this code

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

Everything worked fine in iOS 6. However, in iOS7, the navbar magically disappears.

Here's a screen shot before pushing new VC enter image description here

Here is after pushing it: enter image description here

As you can see, there is a gap between where the content starts and the statusBar, in the position where the navBar should be.

I also tested out this code again on my iOS 6 device, everything is still fine on that iOS 6 device. So I am not sure what's going on here.

Also if I try to log the navBar/navigationItem of the controller where the navbar disappeared, I do get the correct reference to the navBar, which means that it is not nil, but simply not showing.

However, the methodsetHideNavigationBar:NO Animated:NO didn't bring the navBar back either. Does anyone know what's going on?

2
Are those screenshots supposed to be cut off, or is that directly from the simulator?Kyle Clegg
yeah sorry I only captured part of the simulator, so yes they're supposed to be cut off.Enzo
Oh okay, I could hardly see the contrast from the nav bar and wondering what else I was missing. I see it now.Kyle Clegg
Yeah sorry about that. I actually found a temporary solution which just involves setting navBar.translucent = NO. But this leads to other issues as well, eg. my custom menu icon is not showing.Enzo
try to toggle the translucency of navigation bar. self.navigationController.navigationBar.translucent = NO; // YESKhaled Annajar

2 Answers

1
votes

By the way, I've found the solution for this.

It is because in AppDelegate, you might already set some of appearance changes for the Navigation Bar.

So what I suggest you to do is to check the device OS first before set custom apperance for Navigation Bar?

- (BOOL)isOS7
{
    float currentVersion = 7.0;

    if ([[[UIDevice currentDevice] systemVersion] floatValue] < currentVersion)
        return NO;

    return YES;
}

So if return "NO" then only you do whatever possible that can be use for

0
votes

Checkout Autolayout constraints,

I have tried same by using iOS 6 and iOS 7, my navigation bar is showing. Still checkout Autolayout constraints, i have doen it without autolayout