-1
我有一个MKMapKit,并试图根据用户在哪里寻找中心坐标。MKMapView坐标显示0
我用下面的代码获取的坐标了:
float lat = self.mapView.centerCoordinate.latitude;
float lon = self.mapView.centerCoordinate.longitude;
float latDelta = self.mapView.region.span.latitudeDelta;
float lonDelta = self.mapView.region.span.longitudeDelta;
它工作正常,在模拟器上,但有报道0的设备上的所有内容。任何人有任何建议?
谢谢!
此代码是什么?当它“报告0”时,'self.mapView'设置为'nil'?报告如何完成(NSLog,UILabel,其他)?该设备是否与模拟器具有相同的硬件类型和iOS版本? – Anna
@brandontreb你应该使用CLLocationDegrees(又名双)为经纬度等 – Anthony
为什么使用centerCoordinate和地区?试试self.mapView.region.center.latitude和self.mapView.region.center.longitude。正如安娜和阿普拉托所说,绝对检查一个零位mapView并将坐标和长度存储在双精度/ CLLocationDegrees中。 – EricS