iOS8中使用CoreLocation定位
2015-04-08 14:02
441 查看
iOS8对定位进行了一些修改,其中包括定位授权的方法,CLLocationManager增加了下面的两个方法:
(1)始终允许访问位置信息
- (void)requestAlwaysAuthorization;
(2)使用应用程序期间允许访问位置数据
- (void)requestWhenInUseAuthorization;
示例如下:
<span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">1</span> <span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">2</span> <span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">3</span> <span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">4</span> <span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">5</span> <span class="line-number" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; vertical-align: baseline; color: rgb(88, 110, 117) !important;">6</span> | self.locationManager = [[CLLocationManager alloc]init]; _locationManager.delegate = self; _locationManager.desiredAccuracy = kCLLocationAccuracyBest; _locationManager.distanceFilter = 10; [_locationManager requestAlwaysAuthorization];//添加这句 [_locationManager startUpdatingLocation]; |
(1)
NSLocationAlwaysUsageDescription
(2)
NSLocationWhenInUseUsageDescription
这两个键的值就是授权alert的描述,示例配置如下[
勾选Show Raw Keys/Values后进行添加]:
相关文章推荐
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8以前与iOS8使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- 如何在iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中使用CoreLocation定位
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- 关于IOS8的Autolayout特性的理解以及使用
- IOS8 TouchID使用介绍
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- 进入ios8 后使用swift,在使用到UIAlertController(ActionSheet)时适配ipad时挂掉的问题解决方案