CLLocationManager 默认坐标值
我正在学习开发 iOS 应用程序,并且仅在模拟器上尝试它们。现在,在我的应用程序中,我使用 CLLocationManager 来获取我当前的位置坐标。但是,当我运行该应用程序时,无论我在哪里,所有坐标值(海拔、经度、纬度)都会得到相同的结果。即使我搬到另一个地方,它们也不会改变。我想知道 CLLocationManager 如何获取值?如果它在模拟器上不起作用,那么永不改变的值从何而来?根据坐标,我猜这是一个默认值,如果没有可用的坐标,则显示伦敦。
I'm learning to develop iOS apps and I try them on simulater only. Now, in my app I use CLLocationManager to get my current location coordinates. But when I run the app no matter where I am I get the same results for all the coordinate values(altitude,longitude,latitude). They do not change even if I move to another location. What I wonder is how does CLLocationManager get values? If it does not work on simulater then where do the values that never change come from? According to the coordinates I guess it's a default value that shows London if no coordinates are available.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试重置 iOS 模拟器,删除所有应用程序和设置。
当您使用应用程序运行 CLLocationManager 时,它可能会请求使用位置的权限,就像您在设备中看到的那样。
我一直在使用 iOS Simulator,它始终为模拟器提供我的计算机的位置。我猜它受到您的互联网连接和 IP 地址的影响。由于许多计算机没有配备 GPS,因此这是了解计算机位置的唯一方法。
Try Resetting the iOS Simulator, erasing all applications and settings.
And when you run CLLocationManager using application, it will probably ask for permission to use location, something like what you would see in you device.
I've been using iOS Simulator, and it gives location of my computer for the simulator all the time. I guess it's affected by your internet connection and IP address. Since many computers don't come with GPS, it's the only way to know the location of the computer.
模拟器始终给出苹果总部位于库比蒂诺的位置。它不使用计算机的 GPS 或位置。
The simulator always gives the location of Apple headquarters at Cupertino. It does not use computer's gps or location.
模拟器可以使用 skyhook 来检查您与 WiFi 热点绑定的位置(如果添加了坐标),并且如果您在 WiFi 覆盖范围内移动,则您的位置根本不会改变。
Simulator may use skyhook to check your location which is bounded to WiFi hotspot (if it was added with it's coordinates) and if you move in radius of WiFi coverage than your location won't be changed at all.
在菜单栏上,转到调试,然后选择位置、自定义位置,然后您可以输入坐标进行模拟。模拟器并不总是为您提供与设备相同的反馈。
On the menu bar, go to Debug, then select Location, Custom Location and then you can input coordinates to simulate from. The Simulator will not always provide you the same feedback as a device would.