gpt4 book ai didi

ios - 如何使所有对象具有不同的 distanceInMeters?

转载 作者:行者123 更新时间:2023-11-28 16:00:30 25 4
gpt4 key购买 nike

<分区>

感谢您的光临。

问题是所有单元格只有一个 distanceInMeters,所有 100 个对象都具有相同的坐标。如何解决?

感谢您的帮助!

func locationManager(_  manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{


let currentLocation = locations[0]
let coords = CLLocation(latitude: currentLocation.coordinate.latitude, longitude: currentLocation.coordinate.longitude)
if (currentLocation.horizontalAccuracy > 0 ) {
locationManager.stopUpdatingLocation()
}


}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! EateriesTableViewCell
let mall = mallToDisplayAt(indexPath: indexPath)
cell.thumbnailImageView.image = UIImage(named: mall.image)
cell.thumbnailImageView.clipsToBounds = true
cell.nameLabel.text = mall.name
cell.locationLabel.text = mall.location
cell.typeLabel.text = mall.time
let coords = CLLocation()
let mallLocate = CLLocation(latitude: malls[0].latitude, longitude: malls[0].longitude)

let distanceInMeters = mallLocate.distance(from: coords)
let distanceInMetersString = String(distanceInMeters)

cell.distanceLabel.text = distanceInMetersString

return cell

}

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