检索纬度和经度坐标,显示在 UILabel 中
我有兴趣获取用户当前的纬度和经度坐标,并将它们按字面意思显示为视图上 UILabel 中的 NSSString。
我不需要任何 MKMapView 或以图形方式显示任何内容,只需在 UILabel 中显示坐标。这可能吗?
有人可以为我提供一个起点吗?
谢谢
I am interested in grabbing my users current Latitude and Longitude coordinates, and displaying them literally as a NSSString in a UILabel on the view.
I don't need any MKMapView or to show anything graphically, just to display the coordinates in a UILabel. Is this possible?
Could anyone provide a starting block for me?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,有可能。只需导入
#import
并声明委托
。然后您可以通过以下委托方法获取值。Ya, its possible. Just import
#import <CoreLocation/CoreLocation.h>
and declare the delegate<CLLocationManagerDelegate>
. then you can get the values in following delegate mathod.CoreLocation 框架可以完成这项工作。您可以通过实现此委托来获取用户的当前位置。
There is the CoreLocation framework which does this job. You can get the user's current location by implementing this delegate.
请按照以下步骤操作:
将 MapKit.framework 添加到您的项目
add to .h #import "CoreLocation/CoreLocation.h" 和 #import "MapKit/MapKit.h "
使用委托作为 @interface yourInterface : UIViewController < MKMapViewDelegate, CLLocationManagerDelegate >
现在将以下方法添加到您的 .m 文件
这里提到
CLLocationManager *locationManager;
。祝你好运。Follow the steps:
Add MapKit.framework to your project
add to .h #import "CoreLocation/CoreLocation.h" and #import "MapKit/MapKit.h"
Use delegates as, @interface yourInterface : UIViewController < MKMapViewDelegate, CLLocationManagerDelegate >
Now Add following method to your .m file
Here mention
CLLocationManager *locationManager;
. good luck.