Sru*_*mha 13 mkmapview mkannotation swift
我正在尝试自动显示注释标题,而不是在点击时显示它.我使用下面的代码来显示注释并使其在地图上居中.
self.ann.setCoordinate(currentLocation2D)
self.ann.title = "Title"
self.ann.subtitle = "Subtitle"
self.mapView.addAnnotation(self.ann);
self.span = MKCoordinateSpanMake(0.005, 0.005)
self.region = MKCoordinateRegion(center: currentLocation2D, span: self.span)
self.mapView.setRegion(self.region, animated: true)
Run Code Online (Sandbox Code Playgroud)
我能看到的title,subtitle而CalloutAccessoryView当我点击的注解,但是可能无法自动显示.
Chr*_*örz 28
您可以通过使用selectAnnotation并使用mapview.annotations数组来使用它,该数组包含您annotations在地图上拥有的所有数据.
let yourAnnotationAtIndex = 0
mapView.selectAnnotation(mapView.annotations[yourAnnotationAtIndex], animated: true)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8188 次 |
| 最近记录: |