7
che sto cercando di fare un app di navigazioneSWIFT MapView MKRoutePolyline interiorPolygons: selettore non riconosciuta inviati esempio 0x14ed4b4d0
Ma questo incidente app quando ho cercando di navigare e mostrare "MKRoutePolyline
interiorPolygons: selettore non riconosciuta inviati a istanza 0x14ed4b4d0 "
cosa c'è di sbagliato nel mio codice?
import UIKit
import MapKit
class MapViewController: UIViewController, MKMapViewDelegate {
var farm:Farm!
var currentPlacemark:CLPlacemark?
let locationManager = CLLocationManager()
var currentTransportType = MKDirectionsTransportType.Automobile
var currentRoute:MKRoute?
@IBOutlet var mapView:MKMapView!
@IBAction func showDirection(sender: AnyObject){
let directionRequest = MKDirectionsRequest()
directionRequest.source = MKMapItem.mapItemForCurrentLocation()
let destinationPlacemark = MKPlacemark(placemark: currentPlacemark!)
directionRequest.destination = MKMapItem(placemark: destinationPlacemark)
directionRequest.transportType = currentTransportType
let directions = MKDirections(request: directionRequest)
directions.calculateDirectionsWithCompletionHandler { (routeResponse, routeError) -> Void in
guard let routeResponse = routeResponse else {
if let routeError = routeError {
print("Error: \(routeError)")
}
return
}
let route = routeResponse.routes[0]
self.currentRoute = route
self.mapView.removeOverlays(self.mapView.overlays)
self.mapView.addOverlay(route.polyline, level: MKOverlayLevel.AboveRoads)
}
}
func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer {
let renderer = MKPolygonRenderer(overlay: overlay)
renderer.strokeColor = UIColor.yellowColor()
renderer.lineWidth = 3.0
return renderer
}
Potrebbe semplificare il codice con appena il necessario per disegnare nella mappa? – UlyssesR
Grazie per la tua rapida risposta, ma non sono abbastanza sicuro di come semplificare il mio codice ..... –