【发布时间】:2017-12-08 12:05:02
【问题描述】:
我想知道如何操作由 MKAnnotations 组成的数组。这个数组的一个例子是
[<MKUserLocation: 0x608000631500>, <Swift.ColorPointAnnotation: 0x600000861e00>]
但我的问题是,当这个数组生成时,顺序是随机的(MKUserLocation 有时在数组中是第一个,其他时候是第二个)。我想知道是否有一种方法可以抓取,在这种情况下,Swift.ColorPointAnnotation 以便我能够使用此注释操作地图。
这是我操作数组的方式。我希望能够获取特定的注释,以便将 mapRegion 围绕它居中。
let annotations = self.mapView.annotations
let coordinateRegion = MKCoordinateRegionMakeWithDistance((annotations.last?.coordinate)!, 500, 500)
mapView.setRegion(coordinateRegion, animated: true)
【问题讨论】:
标签: ios swift dictionary annotations mkmapview