2
나는 클래스의 배열을 가지고 있습니다. mkmapview에서 몇 가지 주석 핀을 추가합니다. 지도의 대리인으로주석 핀 탭 이벤트 가져 오기 MapKit Swift
var events = [Events]()
for event in events {
let eventpins = MKPointAnnotation()
eventpins.title = event.eventName
eventpins.coordinate = CLLocationCoordinate2D(latitude: event.eventLat, longitude: event.eventLon)
mapView.addAnnotation(eventpins)
}
내가 도청되고있는 배열 events
의 행
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
print(view.annotation?.title! ?? "")
}
는 어떻게 얻을 수있는 기능을 구현했습니다? 다른 ViewController에서 segue하고 싶고이 Class 객체를 보내려고합니다. 당신이 당신의 주석을 추가 할 때 사용자 지정 주석으로 Event
를 연결합니다, 그리고
class EventAnnotation : MKPointAnnotation {
var myEvent:Event?
}
: : 지금
for event in events {
let eventpins = EventAnnotation()
eventpins.myEvent = event // Here we link the event with the annotation
eventpins.title = event.eventName
eventpins.coordinate = CLLocationCoordinate2D(latitude: event.eventLat, longitude: event.eventLon)
mapView.addAnnotation(eventpins)
}
을
정확히 찾고있는 내용입니다. –