ios - 使用代码在 Xcode 中欺骗 iPhone 位置

标签 ios swift xamarin geolocation

对于一个学校项目,我试图使用代码来欺骗我的 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)

这里 selectedLocationCoordinate 的类型为 CLLocationCooperative2D,您可以使用其纬度和经度属性指定其纬度和经度

 selectedLocationCoordinate.latitude =  

 selectedLocationCoordinate.longitude = 

关于ios - 使用代码在 Xcode 中欺骗 iPhone 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44515539/

相关文章:

ios - swift - 在 Controller 之间切换后更新计时器并更新标签

ios - 我无法捕获 WKWebView 的屏幕截图

ios - 当应用程序移至后台时如何使 URLSession 工作

ios - Swift 等待回调在方法返回之前完成

ios - 使用 mediaType Video 从 PHAsset 修改元数据失败

c# - Xamarin 表格 : ScrollView with KeyBoard

iphone - 加载时的设备方向

ios - 找不到 SpriteBuilder 图像文件

android - 在 GridView 适配器 GetView 方法中使用异步方法

c# - 使用 C# 在 Xamarin 中单击外部时,如何防止弹出窗口消失?