Hier ist ein kleines Problem ..MKAnnotationView nicht angezeigt Bild
Ich habe einige Code getan, die das Bild des Stiftes ändern sollte, dass die in mapView fallen gelassen zu bekommen. Die URL von "taxi.png" funktioniert in einer Bildansicht, das ist also nicht das aktuelle Problem.
ich auch versucht:
pinView?.image = UIImage(named: "taxi.png")
Code:
if pinView == nil{
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView?.canShowCallout = true
var imageTaxi = UIImage(named: "taxi.png")!
imageTaxi = imageTaxi.withAlignmentRectInsets(UIEdgeInsetsMake(0, 0, imageTaxi.size.height/2, 0))
pinView?.image = imageTaxi
}
let button = UIButton(type: .detailDisclosure)
pinView?.rightCalloutAccessoryView = button
return pinView
niemand sehen, was hier festgelegt werden soll, um das Bild zu sehen?
EDIT: Ich habe jetzt das und ich habe immer noch die Standard-rot Pinpoint ..
let annotation = CustomPin()
annotation.coordinate = location
annotation.title = "Boek Taxi"
annotation.subtitle = ""
let image = UIImage(named: "taxi.png")
annotation.Image = image
self.mapView.addAnnotation(annotation)
let reuseId = "pin"
var pinView = mapView.dequeueReusableAnnotationView(withIdentifier: reuseId)
if pinView == nil{
pinView = MKPinAnnotationView(annotation: CustomPin() as MKAnnotation, reuseIdentifier: reuseId)
pinView?.canShowCallout = true
} else {
pinView?.annotation = CustomPin() as MKAnnotation
}
let cpa = annotation as! CustomPin
pinView?.image = cpa.Image
let button = UIButton(type: .detailDisclosure)
pinView?.rightCalloutAccessoryView = button
return pinView
}
Irgendwelche Dinge, die ich übersehen?
Haben Sie einen Blick auf diese [Custom Pin Bild] (http://stackoverflow.com/a/38159048/4080925) – MwcsMac
Bestätigen Sie, dass dieser Code überhaupt genannt zu werden (Set Breakpoint und/oder eine Log-Anweisung drucken). Vielleicht wurde der Delegat nicht angegeben oder die Methodensignatur stimmt nicht. Wenn das nicht der Fall ist, klären Sie bitte: Wenn Sie sagen, dass es ein "Problem" gibt, was genau sehen Sie? Roter Stift? Nichts? Absturz? – Rob