iPhone LocationManager - 在应用程序启动时获取坐标
我通过 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
获取位置。当你移动时它应该可以工作(不能在模拟器中真正测试它,至少我不知道如何),但是当我第一次加载应用程序时,地图视图专注于整个世界,而不仅仅是我的位置。我可以调用该方法来更改第一次查看时的位置吗? 这是我当前的代码(如果有帮助的话): http://pastebin.com/9Sb2xVmE http://pastebin.com/rh9WB2ca
I'm getting the location through - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
. It should work when you move (can't really test it in simulator, at least I don't know how) but when I first load the app, the mapview is focused on the whole world, not just my location. Can I anyhow call the method to change the location on first view?
Here is my current code if it helps:
http://pastebin.com/9Sb2xVmE
http://pastebin.com/rh9WB2ca
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用mapkit:
您尝试过吗?
示例:
这应该将地图视图缩放到您想要的大小,同时保持焦点位于中心。
如果您使用 CoreLocation:
这是可能出现问题的清单:
我建议您访问此页面:获取位置使用 Objective-C 的 iOS 设备,并逐步按照教程进行操作。那应该可以帮助你。
另外,这是 Mapkit 文档
祝您的项目好运:]
If your using mapkit:
Have you tried
Example:
this should zoom the mapview to your desired size, while maintaining focus on the center.
If your using CoreLocation:
Heres a checklist of what might have gone wrong:
I advise you to go to this page : Getting location of a iOS device with objective-C and follow the tutorial bit by bit. That should help you out.
Also, heres the mapkit docs
Best of luck with your project :]
我们无法通过在模拟器中运行来获取当前位置。如果您在设备中运行该应用程序,它将显示正确的位置。在模拟器中,它将显示默认位置为 califorina(苹果头四分之一)。
we cant able to get the current location by running it in simulator. if you run the application in device it will show the correct location. In simulator it will show the default loaction as califorina(apple head quaters).