【发布时间】:2018-01-15 11:39:22
【问题描述】:
// 我的视图控制器代码
// AddAnnotation 和 MApView 但我不知道这个问题如果可能的话请上传一个演示代码,因为我是 iOS 新手
private func addAnnotation(coordinate coordinate:CLLocationCoordinate2D, title: String, subtitle: String) {
let coordinatesss = CLLocationCoordinate2D(latitude: 28.56785, longitude: 78.54255)
addAnnotation(coordinate: coordinates , title: "titles" , subtitle: "subtitles")
mapView.addAnnotation(annotation)
}
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation { return nil }
let coordinates = CLLocationCoordinate2D(latitude: 28.56785, longitude: 78.54255)
let identifier = "CustomAnnotation"
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier)
if annotationView == nil {
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: identifier)
annotationView!.canShowCallout = true
annotationView!.image = UIImage(named: "star.png")!
} else {
annotationView!.annotation = annotation
}
return annotationView
}
【问题讨论】:
-
请显示此代码的更多上下文。
标签: ios swift annotations mapkit