Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 如何使用CLLocationDegrees解决此问题?_Swift_Xcode_Mapkit - Fatal编程技术网

Swift 如何使用CLLocationDegrees解决此问题?

Swift 如何使用CLLocationDegrees解决此问题?,swift,xcode,mapkit,Swift,Xcode,Mapkit,我试图根据表视图中单元格的数量打开不同的位置,因此我编写了以下函数: func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let latitude: CLLocationDegrees = self.latitudes[indexPath.row] let longitude: CLLocationDegrees = self.l

我试图根据表视图中单元格的数量打开不同的位置,因此我编写了以下函数:

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”)


有人知道我该怎么做吗?

你传递的是
纬度
而不是
纬度
作为
CLLocationCoordinate2DMake
的第一个参数,也许你的纬度是一个纬度数组?是的,它们都是数组,我已经指定了从数组中获取哪一项并发现了你的错误,将坐标改为(纬度,经度),如果(纬度,经度)