对于一个学校项目,我试图使用代码欺骗我的iPhone的位置。我已经知道"调试>模拟位置"选项,但我想知道我是否可以使用框架或通过代码或类似的东西传递 GPX 数据以某种方式欺骗它。
例如,在Android中,您可以简单地执行以下操作:
location.setLatitude(latitude);
location.setLongitude(longitude);
这在Xcode/Xamarin中也有可能吗?
您可以使用 MkMapView 的 setRegion 函数
let region: MKCoordinateRegion = MKCoordinateRegionMakeWithDistance(selectedLocationCoordinate, 1000, 1000)
mapView.setRegion(region, animated: true)
此处选择的位置坐标为 CLLocationCoordinate2D 类型,您可以使用其纬度和经度属性指定其纬度和经度
selectedLocationCoordinate.latitude =
selectedLocationCoordinate.longitude =