Ich habe mehrere Pins auf meiner Karte zum Beispiel entsprechend verschiedenen Brückenstandorten gesetzt. Jeder dieser Pins hat eine eigene Anmerkung, wenn er angeklickt wird, die seinen Titel und Untertitel anzeigt. Ich habe in diesen Anmerkungen eine Info-Schaltfläche hinzugefügt. Ich weiß jedoch nicht, wie man einen neuen UiViewController öffnet, der die auf dem UiViewController angezeigten Informationen abhängig davon, welche Bridge-Info-Taste gedrückt wird, variiert.Wie Sie die Callout-Taste verwenden, um den neuen uiviewcontroller zu öffnen. (Swift)
Also im Grunde muss ich wissen, wie: 1: Öffnen Sie einen UiViewController, wenn die Info-Taste in der Anmerkung gedrückt wird. 2: Variieren Sie die Informationen zu den UiViewController-Ausgaben, welche der Brücken-Infotasten gedrückt werden.
Hier ist, was ich bisher:
mapView.delegate = self
//bridges
var Bridge1 = CLLocationCoordinate2DMake(48.60,2.90)
var bridge2 = CLLocationCoordinate2DMake(48.61, 2.91)
var bridge3 = CLLocationCoordinate2DMake(48.62, 2.92)
var bridge4 = CLLocationCoordinate2DMake(48.63, 2.93)
var bridge5 = CLLocationCoordinate2DMake(48.64, 2.94)
var bridge6 = CLLocationCoordinate2DMake(48.65, 2.95)
var span = MKCoordinateSpanMake(0.4, 0.4)
var region = MKCoordinateRegion(center: Bridge1, span: span)
mapView.setRegion(region, animated: true)
var Bridge1pin = MKPointAnnotation()
Bridge1pin.coordinate = Bridge1
Bridge1pin.title = "Bridge1"
Bridge1pin.subtitle = "This is bridge 1"
mapView.addAnnotation(Bridge1pin)
var bridge2pin = MKPointAnnotation()
bridge2pin.coordinate = bridge2
bridge2pin.title = "Bridge2"
bridge2pin.subtitle = "This is bridge 2"
mapView.addAnnotation(bridge2pin)
var bridge3pin = MKPointAnnotation()
bridge3pin.coordinate = bridge3
bridge3pin.title = "Bridge3"
bridge3pin.subtitle = "This is bridge 3"
mapView.addAnnotation(bridge3pin)
var bridge4pin = MKPointAnnotation()
bridge4pin.coordinate = bridge4
bridge4pin.title = "Bridge4"
bridge4pin.subtitle = "This is bridge 4"
mapView.addAnnotation(bridge4pin)
var bridge5pin = MKPointAnnotation()
bridge5pin.coordinate = bridge5
bridge5pin.title = "bridge5"
bridge5pin.subtitle = "hello this is bridge 5"
mapView.addAnnotation(bridge5pin)
var bridge6pin = MKPointAnnotation()
bridge6pin.coordinate = bridge6
bridge6pin.title = "bridge6"
bridge6pin.subtitle = "hello this is bridge 6"
mapView.addAnnotation(bridge6pin)
}
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
let reuseIdentifier = "pin"
var pin = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseIdentifier) as? MKPinAnnotationView
if pin == nil {
pin = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseIdentifier)
pin!.pinColor = .Red
pin!.canShowCallout = true
pin!.rightCalloutAccessoryView = UIButton(type: .DetailDisclosure)
} else {
pin!.annotation = annotation
}
return pin
}
}