gpt4 book ai didi

ios - 是否有预设 'index' 或类似的东西允许我引用用户创建的特定注释? swift 4

转载 作者:行者123 更新时间:2023-11-28 07:39:29 24 4
gpt4 key购买 nike

我有一个应用程序,用户可以在其中搜索位置,点击表格 View 中的行,然后将在地标处放置注释。我有一个按钮“meetUpButton”,允许他们放置多个注释,而不是我的代码默认执行的操作,即如果单击新的搜索结果则删除注释。有没有办法引用我的用户创建的特定注释,即使他们创建了多个注释?例如,假设我想添加我的用户创建的两个注释的纬度...如果我有

let annotation = MKPointAnnotation()
annotation.coordinate.latitude

有没有一种方法可以引用索引为 0 的第一个注释和我的用户使用 1 或其他方式选择的下一个注释?这是我的一些代码,可能会使这一点更清楚。

extension ViewController: handleMapSearch {
func dropPinZoomIn(placemark:MKPlacemark) {
resultSearchController?.isActive = false

// cache the pin
selectedPin = placemark
// clear existing pins
if meetUpOutlet.isEnabled == true {

mapView.removeAnnotations(mapView.annotations)

} else {

}

let annotation = MKPointAnnotation()

annotation.coordinate = placemark.coordinate
annotation.title = placemark.name
if let city = placemark.locality,
let state = placemark.administrativeArea {
annotation.subtitle = "(\(city)) (\(state))"
}
mapView.addAnnotation(annotation)
let span = MKCoordinateSpanMake(0.05, 0.05)
let region = MKCoordinateRegionMake(placemark.coordinate, span)
mapView.setRegion(region, animated: true)
}
}

最佳答案

你可以尝试使用 MKMapView 实例的 annotations 属性,来获得所有使用

let anns = self.mapView.annotations 

关于ios - 是否有预设 'index' 或类似的东西允许我引用用户创建的特定注释? swift 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52636800/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com