In Swift werde ich versuchen, Pin Position (zPosition) auf Top setzen, ich bin 10 Pin auf Karte, Aktuelle Pin (Any Pin) oben zeigt und diese aktuelle Pin Bild ist ändern Bitte, aber es ist nicht an der Spitze zeigt, hilf mir hier mein Code I Try haben diesen CodeSwift viewForAnnotation pin zposition nicht oben
// pinView!.layer.zPosition = 1
//pinView?.bringSubviewToFront(self.view)
pinView!.superview!.bringSubviewToFront(view)
App Absturz auf diese Linien
pinView!.superview!.bringSubviewToFront(view)
und seine Rückkehr mich fataler Fehler: unerwartet beim Auspacken nil gefunden Ein optionaler Wert mir bitte helfen Wie hier zeigen Anpinnen
mein Code
func mapView(mapView: MKMapView,
viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView?{
if annotation is MyAnnotation == false{
return nil
}
/* First typecast the annotation for which the Map View has
fired this delegate message */
let senderAnnotation = annotation as! MyAnnotation
// -------------------------- For ios 9 -------------------
let reuseId = "pin"
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if pinView == nil {
pinView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.canShowCallout = true
}else{
pinView!.annotation = annotation
}
pinView!.tag = senderAnnotation.getTag;
// print(senderAnnotation.getTag)
if annotation is MyAnnotation {
print(senderAnnotation.pinColor)
if(senderAnnotation.pinColor == .Red)
{
if(currentIndex == senderAnnotation.getTag)
{
print("currentIndex==\(currentIndex)********")
pinView!.image = UIImage(named: "jivemap_pin_rough_o.png")
// pinView!.layer.zPosition = 1
//pinView?.bringSubviewToFront(self.view)
pinView!.superview!.bringSubviewToFront(view)
}else
{
pinView!.image = UIImage(named: "jivemap_pin_rough_g.png")
}
}
else
{
if(currentIndex == senderAnnotation.getTag)
{
print("currentIndex==*********\(currentIndex)********")
pinView!.image = UIImage(named: "jivemap_pin_o.png")
// pinView!.layer.zPosition = 1
//pinView?.bringSubviewToFront(self.view)
pinView!.superview!.bringSubviewToFront(view)
}else
{
pinView!.image = UIImage(named: "jivemap_pin_g.png")
}
}
pinView!.rightCalloutAccessoryView = UIButton(type: UIButtonType.DetailDisclosure) as UIView
// pinView
// return pinView
}
return pinView
//return annotationView
}
ist habe ich ein weiteres Problem, Können wir wählen den Zoom, die 10 Pins alle zusammen zeigen Beliebig Lösung Für diesen Punkt, wie man Zoomhebel einstellt, Kameraebene, um alle 10 Stifte auf Kartenansicht zu zeigen Wenn ich nach diesen Punkten suche, fand ich diesen Code, aber ich kann nicht verstehen, wie man diesen Code benutzt.
CGFloat latDelta = rand()*0.125/RAND_MAX - 0.02;
CGFloat lonDelta = rand()*0.130/RAND_MAX - 0.08;
CGFloat lat = 59.189358;
CGFloat lng = 18.267839;
CLLocationCoordinate2D newCoord = {lat+latDelta, lng+lonDelta};
DTSAnnotation *annotation = [DTSAnnotation annotationWithCoord:newCoord];
mir bitte helfen
Vielleicht helfen ein paar Screenshots. – Lumialxk
OK, ich werde hinzufügen, aber das Problem ist, ich habe 10 Pins 9 Pin sind gleich und 1 Pin ist ein anderes Bild, so dass diese eine Pin nicht zu anderen Pins zurück, die ich oben setzen muss –