Я новичок в кодировании, и мне нужно превратить аннотацию в UIButton
.Моя цель состоит в том, чтобы пользователи нажимали кнопку, и она переключалась на другой UIView, похожий на Карты Google или Карты Apple .
Как я смогу закодировать кнопку, чтобы при нажатии на нее отображался UIView?
Вот что у меня есть:
func displayCordinates() {
ref = Database.database().reference()
let storageRef = ref.child("waterfountains")
storageRef.observeSingleEvent(of: .value, with: { snapshot in
for child in snapshot.children.allObjects as! [DataSnapshot] {
let annotation = CustomPointAnnotation()
let dict = child.value as? [String : AnyObject] ?? [:]
annotation.title = "Water Fountain"
annotation.tag = dict["url"]
annotation.coordinate = CLLocationCoordinate2D(latitude: dict["lat"] as! Double, longitude: dict["long"] as! Double)
self.mapView.addAnnotation(annotation)
let reuseId = "pin"
var pinView = self.mapView.dequeueReusableAnnotationView(withIdentifier: reuseId) as? MKPinAnnotationView
var rightCalloutAccessoryView: UIView!
if pinView == nil {
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.canShowCallout = true
pinView!.rightCalloutAccessoryView = UIButton(type: .detailDisclosure) as UIButton
}
else {
pinView!.annotation = annotation
}
}
})
}
func mapView(MapView: MKMapView!, annotationView: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
if control == annotationView.rightCalloutAccessoryView {
performSegue(withIdentifier: "toUploadScreen", sender: self)
print("Going to the next VC!")
}
}
`
После того, как он выполнил переход, он должен напечатать« Переход к следующему VC », но этоне печатать, поэтому что-то в коде должно быть сломано, и я не могу понять, что.