Skip to content

fix setup && bugs #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 54 additions & 164 deletions Navigation-Examples.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions Navigation-Examples/ExampleContainerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class ExampleContainerViewController: UITableViewController {
var hasEnteredExample = false
var pushExampleToViewController = false

var currentViewController: UIViewController?

override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = exampleName
Expand All @@ -29,8 +31,10 @@ class ExampleContainerViewController: UITableViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if hasEnteredExample {
if let last = view.subviews.last {
last.removeFromSuperview()
if let last = currentViewController {
last.willMove(toParent: nil)
last.view.removeFromSuperview()
last.removeFromParent()
hasEnteredExample = false
}
}
Expand All @@ -48,6 +52,8 @@ class ExampleContainerViewController: UITableViewController {
private func embed(controller: UIViewController, shouldPush: Bool) {
addChild(controller)
view.addSubview(controller.view)

self.currentViewController = controller

controller.didMove(toParent: self)
if shouldPush {
Expand Down
15 changes: 3 additions & 12 deletions Navigation-Examples/Examples/Advanced.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,8 @@ class AdvancedViewController: UIViewController, NavigationMapViewDelegate, Navig
credentials: NavigationSettings.shared.directions.credentials,
simulating: simulationIsEnabled ? .always : .onPoorGPS)

let navigationOptions = NavigationOptions(navigationService: navigationService,
// Replace default `NavigationMapView` instance with instance that is used in preview mode.
navigationMapView: navigationMapView)

let navigationViewController = NavigationViewController(for: indexedRouteResponse,
navigationOptions: navigationOptions)
let navigationViewController = NavigationViewController(navigationService: navigationService)
navigationViewController.delegate = self
navigationViewController.modalPresentationStyle = .fullScreen

Expand Down Expand Up @@ -186,10 +182,8 @@ class AdvancedViewController: UIViewController, NavigationMapViewDelegate, Navig

self.routeResponse = response
self.startButton?.isHidden = false
if let routes = self.routes,
let currentRoute = self.currentRoute {
self.navigationMapView.show(routes)
self.navigationMapView.showWaypoints(on: currentRoute)
if let routes = self.routes {
self.navigationMapView.showcase(routes)
}
}
}
Expand Down Expand Up @@ -220,9 +214,6 @@ class AdvancedViewController: UIViewController, NavigationMapViewDelegate, Navig
// delegate should be re-assigned back to `NavigationMapView` that is used in preview mode.
self.navigationMapView.delegate = self

// Replace `NavigationMapView` instance with instance that was used in active navigation.
self.navigationMapView = navigationViewController.navigationMapView

// Since `NavigationViewController` uses `UserPuckCourseView` as a default style
// of the user location indicator - revert to back to default look in preview mode.
self.navigationMapView.userLocationStyle = .puck2D()
Expand Down
1 change: 1 addition & 0 deletions Navigation-Examples/Examples/Basic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UIKit
import MapboxCoreNavigation
import MapboxNavigation
import MapboxDirections
import CoreLocation

class BasicViewController: UIViewController {
override func viewDidLoad() {
Expand Down
1 change: 1 addition & 0 deletions Navigation-Examples/Examples/Custom-RoutingProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UIKit
import MapboxCoreNavigation
import MapboxNavigation
import MapboxDirections
import CoreLocation

/*
This example demonstrates how users can control and customize the rerouting process.
Expand Down
12 changes: 6 additions & 6 deletions Navigation-Examples/Examples/Custom-Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CustomServerViewController: UIViewController {
case .failure(let error):
print(error.localizedDescription)
case .success(let response):
guard let strongSelf = self else {
guard let self = self else {
return
}

Expand All @@ -41,12 +41,12 @@ class CustomServerViewController: UIViewController {
credentials: NavigationSettings.shared.directions.credentials,
simulating: simulationIsEnabled ? .always : .onPoorGPS)
let navigationOptions = NavigationOptions(navigationService: navigationService)
strongSelf.navigationViewController = NavigationViewController(for: indexedRouteResponse,
let navigationViewController = NavigationViewController(for: indexedRouteResponse,
navigationOptions: navigationOptions)
strongSelf.navigationViewController?.modalPresentationStyle = .fullScreen
strongSelf.navigationViewController?.delegate = strongSelf

strongSelf.present(strongSelf.navigationViewController!, animated: true, completion: nil)
navigationViewController.modalPresentationStyle = .fullScreen
navigationViewController.delegate = self
self.navigationViewController = navigationViewController
self.present(navigationViewController, animated: true, completion: nil)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Navigation-Examples/Examples/Custom-Voice-Controller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import MapboxNavigation
import MapboxDirections
import MapboxSpeech
import AVFoundation
import CoreLocation

class CustomVoiceControllerUI: UIViewController {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import UIKit
import MapboxCoreNavigation
import MapboxNavigation
import MapboxDirections
import CoreLocation

class CustomBarsViewController: UIViewController {
override func viewDidLoad() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Xg4-Po-kzu">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Xg4-Po-kzu">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -12,7 +12,7 @@
<!--NavigationViewController-->
<scene sceneID="cSe-rV-QHv">
<objects>
<viewControllerPlaceholder storyboardName="Navigation" bundleIdentifier="org.cocoapods.MapboxNavigation" referencedIdentifier="NavigationViewController" id="h9f-3d-YgW" sceneMemberID="viewController">
<viewControllerPlaceholder storyboardName="Navigation" bundleIdentifier="MapboxNavigation" referencedIdentifier="NavigationViewController" id="h9f-3d-YgW" sceneMemberID="viewController">
<navigationItem key="navigationItem" id="DSp-2V-mUu"/>
</viewControllerPlaceholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="cKf-ee-17W" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import UIKit
import MapboxNavigation
import MapboxCoreNavigation
import MapboxDirections
import CoreLocation

class SegueViewController: UIViewController {

Expand Down
1 change: 1 addition & 0 deletions Navigation-Examples/Examples/Predictive-Caching.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import UIKit
import MapboxCoreNavigation
import MapboxNavigation
import MapboxDirections
import CoreLocation

class PredictiveCachingViewController: UIViewController {
override func viewDidLoad() {
Expand Down
2 changes: 1 addition & 1 deletion Navigation-Examples/Examples/Route-Alerts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class TopAlertsBarViewController: ContainerViewController {

// To change top banner size and position change layout constraints directly.
let topAlertsBannerViewConstraints: [NSLayoutConstraint] = [
topAlertsBannerView.topAnchor.constraint(equalTo: view.topAnchor, constant: 10),
topAlertsBannerView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 10),
topAlertsBannerView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 60),
topAlertsBannerView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -60),
topAlertsBannerView.heightAnchor.constraint(equalToConstant: 100.0),
Expand Down
1 change: 1 addition & 0 deletions Navigation-Examples/Examples/Route-Deserialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import UIKit
import MapboxCoreNavigation
import MapboxNavigation
import MapboxDirections
import CoreLocation

class RouteDeserializationViewController: UIViewController {

Expand Down
1 change: 1 addition & 0 deletions Navigation-Examples/Examples/Route-Initialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import MapboxCoreNavigation
import MapboxNavigation
import MapboxDirections
import Turf
import CoreLocation

class RouteInitializationViewController: UIViewController {

Expand Down
Loading