Skip to main content

Storyboards

A newer version of the Navigation SDK is available

This page uses v1.4.2 of the Mapbox Navigation SDK. A newer version of the SDK is available. Learn about the latest version, v2.19.0, in the Navigation SDK documentation.

To set up Mapbox Navigation in a storyboard:

  • Open the object library and drag in a Storyboard Reference.

  • Pick Navigation from the dropdown and set bundle to com.mapbox.MapboxNavigation (org.cocoapods.MapboxNavigation if you are using CocoaPods)

  • Set up a segue to the storyboard reference like you would to any other UIViewController.

You also need to pass a route and optionally a directions instance to the NavigationViewController. To do that, override your UIViewController's prepare(for:sender:):

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
switch segue.identifier ?? "" {
case "MyNavigationSegue":
if let controller = segue.destination as? NavigationViewController {
controller.route = route
controller.directions = directions
}
default:
break
}
}