在Info.plist中加入两个缺省没有的字段(自定义提示用户授权使用地理定位功能时的提示语
)
- NSLocationAlwaysUsageDescription (string类型)
-
NSLocationWhenInUseUsageDescription
#import
<CoreLocation/CoreLocation.h>
//#import <MapKit/MapKit.h>
#define IS_IOS8 ([[[UIDevice currentDevice] systemVersion] floatValue] >=
8
)
@property
(
strong
,
nonatomic
)
CLLocationManager
*locationManager;
@property
(
nonatomic
,
strong
)
CLGeocoder
*geo;
@property
(
nonatomic
,
copy
)
NSString
*locationCity;
//
NSLocationWhenInUseUsageDescription
@property ( nonatomic , strong ) CLGeocoder *geo;

本文介绍了如何在iOS应用中实现地理位置定位,包括在Info.plist中添加授权提示,使用CLLocationManager进行定位,以及通过CLGeocoder反向编码获取详细地址。代码示例展示了iOS8及以上版本如何请求始终允许访问位置信息。
最低0.47元/天 解锁文章
2359

被折叠的 条评论
为什么被折叠?



