简体   繁体   中英

Navigation Bar not showing with Push Segue on iOS 7

I have a push segue between one view controller and another. When the selects a certain option from an action sheet, the segue is performed and the view appears. I created the segue as per this answer .

On iOS 8, this works fine. The view is added to the navigation controller and a back button appears automatically. On iOS 7 however, I've just noticed that the view appears as a modal and doesn't show the Navigation Bar at all. I don't know when this started happening, but I can't seem to figure out why.

When the action sheet item is pressed, I use:

[self performSegueWithIdentifier:@"showRouteInformationFromMap" sender:nil];

to call the segue. I prepare the segue using:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([[segue identifier] isEqualToString:@"showRouteInformationFromMap"]) {
        [[segue destinationViewController] setRouteInfo:selectedRouteID];
    }
}

Which just assigns a value on the destination controller. I don't make any changes to the Navigation Bar on either view controller.

Try to remove your segue in storyboard and create a segue again. This approach worked for me in iOS 10.

2 workarounds are there.

the show segue is introduced in iOS 8 and hence the unexpected behavior in 7 is very much expected.

1st workaround: push your controller manually

UIViewController *myController = [self.storyBoard.instantiateViewControllerWithIdentifier:@"storyboardIdentifier"];
self.navigationController pushViewController:myController animated:YES];

2nd workaround: Using storyboard

disconnect the show segue and connect the push segue (displayed as deprecated).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM