我正在尝试在使用CoreLocation的Xcode 11模拟器上测试一个应用程序。我想使用模拟器中 Debug> Location 下的“ Freeway Drive”位置选项来测试MapKit折线叠加层。
很遗憾,地图上没有任何行,并且在日志中多次打印了“编译器错误:无效的库文件”。
这似乎不是代码问题,而是更多的Xcode问题。有没有办法解决?用物理设备进行测试非常困难,因为在受限空间中的移动并不会真正被CoreLocation吸收。
谢谢!
我正在尝试在使用CoreLocation的Xcode 11模拟器上测试一个应用程序。我想使用模拟器中 Debug> Location 下的“ Freeway Drive”位置选项来测试MapKit折线叠加层。
很遗憾,地图上没有任何行,并且在日志中多次打印了“编译器错误:无效的库文件”。
这似乎不是代码问题,而是更多的Xcode问题。有没有办法解决?用物理设备进行测试非常困难,因为在受限空间中的移动并不会真正被CoreLocation吸收。
谢谢!
只需定义折线并将其“推送”到您的mapView中:
let polyline = MKPolyline(coordinates: locations,count: locations.count)
mapView.addOverlays([polyline])
并声明mkMapViewDelegate的功能:
//MKMapViewDelegate
func mapView(_ mapView: MKMapView,rendererFor overlay: MKOverlay) ->
MKOverlayRenderer
{
if let mapPolyline = overlay as? MKPolyline {
let polyLineRenderer = MKPolylineRenderer(polyline: mapPolyline)
polyLineRenderer.strokeColor = .darkGray
polyLineRenderer.lineWidth = 4.0
return polyLineRenderer
}
fatalError("Polyline Renderer could not be initialized" )
}
它应该在mapView上显示折线。 我也遇到了编译器错误,请尝试修复它。
最佳 德拉甘