Custom segue
Create an instance of NavigationViewController from UIStoryboardSegue.
/*This code example is part of the Mapbox Navigation SDK for iOS demo app,which you can build and run: https://github.com/mapbox/mapbox-navigation-ios-examplesTo learn more about each example in this app, including descriptions and linksto documentation, see our docs: https://docs.mapbox.com/ios/navigation/examples/custom-segue*/ import UIKitimport MapboxNavigationimport MapboxCoreNavigationimport MapboxDirections class SegueViewController: UIViewController { var routeResponse: RouteResponse! var navigationOptions: NavigationOptions! @IBOutlet weak var presentNavigationButton: UIButton! override func viewDidLoad() {super.viewDidLoad() setupPresentNavigationButton() let origin = CLLocationCoordinate2DMake(37.77440680146262, -122.43539772352648)let destination = CLLocationCoordinate2DMake(37.76556957793795, -122.42409811526268)let navigationRouteOptions = NavigationRouteOptions(coordinates: [origin, destination]) Directions.shared.calculate(navigationRouteOptions) { [weak self] (_, result) inswitch result {case .failure(let error):NSLog("Error occured: \(error.localizedDescription).")case .success(let response):guard let self = self else { return } self.routeResponse = response let indexedRouteResponse = IndexedRouteResponse(routeResponse: response, routeIndex: 0)let navigationService = MapboxNavigationService(indexedRouteResponse: indexedRouteResponse,customRoutingProvider: NavigationSettings.shared.directions,credentials: NavigationSettings.shared.directions.credentials,simulating: simulationIsEnabled ? .always : .onPoorGPS)self.navigationOptions = NavigationOptions(navigationService: navigationService)}}} func setupPresentNavigationButton() {presentNavigationButton.titleLabel?.textAlignment = .centerpresentNavigationButton.titleLabel?.numberOfLines = 2presentNavigationButton.titleLabel?.lineBreakMode = .byTruncatingTail} override func prepare(for segue: UIStoryboardSegue, sender: Any?) {// To create an instance of `NavigationViewController`// from `UIStoryboardSegue` `route`, `routeIndex` and `routeOptions`// properties of `NavigationViewController` must be pre-defined.switch segue.identifier ?? "" {case "NavigationSegue":if let navigationViewController = segue.destination as? NavigationViewController {let indexedRouteResponse = IndexedRouteResponse(routeResponse: routeResponse, routeIndex: 0)_ = navigationViewController.prepareViewLoading(indexedRouteResponse: indexedRouteResponse)// `navigationOptions` property is optional.navigationViewController.navigationOptions = navigationOptionsnavigationViewController.delegate = selfnavigationViewController.modalPresentationStyle = .fullScreen}default:break}}} extension SegueViewController: NavigationViewControllerDelegate { func navigationViewControllerDidDismiss(_ navigationViewController: NavigationViewController, byCanceling canceled: Bool) {dismiss(animated: true)}}