【发布时间】:2020-03-29 17:53:06
【问题描述】:
import SwiftUI
import Mapbox
import MapboxAnnotationExtension
import MapboxDirections
import MapboxCoreNavigation
import MapboxNavigation
/****** some classes for different types of annotations
struct MapboxRepresent: UIViewRepresentable {
................
class Coordinator: NSObject, MGLMapViewDelegate {
func mapView(_ mapView: MGLMapView, tapOnCalloutFor annotation: MGLAnnotation) {
let navigationViewController = NavigationViewController(for: directionsRoute!)
navigationViewController.modalPresentationStyle = .fullScreen
!!!! -> present(navigationViewController, animated: true, completion: nil)
// here is error - Use of unresolved identifier 'present'
}
}
.................
}
此代码正常工作;它显示地图和所有注释。 tap 的功能仅用于测试。由于我是 SwiftUI5 的新手,我无法理解如何解决这个问题。
【问题讨论】:
-
present是一个UiViewController方法。您名为Coordinator的对象继承自NSObject和MGLMapViewDelegate但不是UIViewController因此未解析的标识符。它不知道present方法是什么,因为它确实不应该。 -
我知道。问题是我不明白我必须在哪个地方激活导航
标签: ios navigation mapbox