首页 > 解决方案 > 如何用 CLLocationDegrees 解决这个问题?

问题描述

我试图根据表格视图中单元格的数量打开不同的位置,所以我写了这个函数:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

              let latitude: CLLocationDegrees = self.latitudes[indexPath.row]
               let longitude: CLLocationDegrees = self.longitude[indexPath.row]
              let coordinate = CLLocationCoordinate2DMake(latitudes,longitude)
              let mapItem = MKMapItem(placemark: MKPlacemark(coordinate: coordinate, addressDictionary:nil))
              mapItem.openInMaps(launchOptions: [MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving])
    }

但是,Xcode 给了我这个错误“无法将类型'[CLLocationDegrees]'(又名'Array')的值转换为预期的参数类型'CLLocationDegrees'(又名'Double')”

有人知道我该怎么办吗?

标签: swiftxcodemapkit

解决方案


推荐阅读