gpt4 book ai didi

ios - 在 uiview 中显示引脚信息

转载 作者:行者123 更新时间:2023-11-28 15:40:56 25 4
gpt4 key购买 nike

我正在使用一个应用程序,这个应用程序使用 mapkit,现在我可以显示用户当前位置,当我点击一个图钉时我可以显示信息,但我想做的是显示 map View 上 uiview 中的图钉信息,因此当我点击图钉时,信息应该出现在 uiview 的标签中,而不是出现在图钉上。这是我的代码和屏幕截图。

希望你能帮助我

    let locations = hardCodedLocationData()

var annotations = [MKPointAnnotation]()

for dictionary in locations {

let lat = CLLocationDegrees(dictionary["latitude"] as! Double)
let lon = CLLocationDegrees(dictionary["longitude"]as! Double)

let coordinate = CLLocationCoordinate2D(latitude: lat, longitude: lon)
let name = dictionary["nombre"] as! String
let adress = dictionary["direccion"] as! String

let annotation = MKPointAnnotation()
annotation.coordinate = coordinate
annotation.title = "\(name)"
annotation.subtitle = "\(adress)"
annotations.append(annotation)
}

self.mapView.addAnnotations(annotations)
}

func hardCodedLocationData() -> [[String : AnyObject]] {
return[
["nombre" : "xxxxxxx" as AnyObject,
"direccion" : "xxxxxxxx" as AnyObject,
"latitude" : 19.43017222686738 as AnyObject,
"longitude" : -99.20263767242432 as AnyObject],
["nombre" : "xxxxxxxxxx " as AnyObject,
"direccion" : "xxxxxxxxxxx" as AnyObject,
"latitude" : 19.434057416826118 as AnyObject,
"longitude" : -99.19233798980713 as AnyObject],

[ "nombre" : "xxxxxxxxxxx" as AnyObject,
"direccion" : "xxxxxxxxxx" as AnyObject,
"latitude" : 19.43017222686738 as AnyObject,
"longitude" : -99.19692993164062 as AnyObject]
]


}

This is the mapView

最佳答案

抱歉,我无法发表评论,因为还没有所需的相关要点,但我相信以下功能应该对您有所帮助:

func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
if view is MKPinAnnotationView {
yourLabel.text = //call up text
}
}

//or change if view is to
if let views = view as? MKPinAnnotationView {
//do your updating of labels
}

关于ios - 在 uiview 中显示引脚信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43686097/

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