Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 10 Beta makes navigation bar buttons and title disappear on pushViewController

EDIT: Please watch the video of my issue here: https://www.dropbox.com/sh/lzgs9mahx5mea13/AADLYfLQix7MDleDN1ER81qVa?dl=0

I have had an app live in app store which works perfectly fine on iOS 9.

However on iOS 10 (tested on device iPhone 6s with latest beta), when the cell on the master view controller is selected and the detail view is "pushed", my navigation bar's title and navigation bar buttons disappear.

Only the back button is visible.

Even if I pop back to the master by clicking back button or swiping back, they don't come back. After popping back, even the "master's" title and bar buttons are gone. I have no clue how to troubleshoot this as there are no errors.

IN my code, I am not hiding the navigation bar anywhere nor doing anything fancy with the navigation controller.

Screenshots from view hierarchy insprector: enter image description here

Notice how the title and my right bar buttons on behind a few other views. the back button is at the very front. This shows that the buttons and title are not hidden, they are being covered by 3 extra views: UIVisualEffectView, _UIVisualEffectBackdropView and _UIVIsualEffectFilterView

Also in the video, you will notice that if i do a half swipe back, then cancel the swipe, the bar buttons come back. But the title doesn't.

enter image description here

enter image description here

After returning to the master, notice the master's nav bar stuff is overlaid with 2 other private class views: enter image description here

I push to detail programmatically: Relevant code:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];

    PlaylistDetailViewController *pdvc = (PlaylistDetailViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"PlaylistDetailViewController"];
    pdvc.indexPath=indexPath;
    [self.navigationController pushViewController:pdvc animated:YES];
}
like image 452
sudoExclaimationExclaimation Avatar asked Aug 29 '16 17:08

sudoExclaimationExclaimation


2 Answers

I ran into this problem too, and all the solutions suggested so far are either:

  1. too complicated
  2. doesn't work

In the end I found out that this was caused because of the updated draw cycle for UINavigationBar in iOS10.

To get around this I had to fix it with:

self.navigationController.navigationBarHidden = YES;
self.navigationController.navigationBarHidden = NO;

It's basically triggering the navigationbar to redraw.

It's still annoying how they can just push out a new version of OS that breaks something this significant.

like image 94
Vlad Avatar answered Oct 27 '22 21:10

Vlad


I ran into this same issue but it was caused from using a custom UINavigationBar that was adding a blur view. It looks like something has changed with iOS10 that when adding a title or buttons to the navigation bar they are being added at a specific index instead of being appended to the subview stack.

I was able to overcome this issue by overriding the method insertSubview:atIndex and making sure the blurView was always inserted at the back of the subview stack.

like image 26
psychoticidiot Avatar answered Oct 27 '22 23:10

psychoticidiot