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
的第一个参数,也许你的纬度是一个纬度数组?是的,它们都是数组,我已经指定了从数组中获取哪一项并发现了你的错误,将坐标改为(纬度,经度),如果(纬度,经度)