zoukankan      html  css  js  c++  java
  • CoreLocation在iOS8上用法的变化

    1、在使用CoreLocation前需要调用如下函数【iOS8专用】:

    iOS8对定位进行了一些修改,其中包括定位授权的方法,CLLocationManager增加了下面的两个方法:

    (1)始终允许访问位置信息

    - (void)requestAlwaysAuthorization;

    (2)使用应用程序期间允许访问位置数据

    - (void)requestWhenInUseAuthorization;

    示例如下:

    self.locationManager = [[CLLocationManager alloc]init];
    _locationManager.delegate = self;
    _locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    _locationManager.distanceFilter = 10;
    [_locationManager requestAlwaysAuthorization];//添加这句
    [_locationManager startUpdatingLocation];

    2、在Info.plist文件中添加如下配置:

    (1)NSLocationAlwaysUsageDescription

    (2)NSLocationWhenInUseUsageDescription

    这两个键的值就是授权alert的描述,示例配置如下[勾选Show Raw Keys/Values后进行添加]:

    ios8_location_info_plist.png

  • 相关阅读:
    QQ列表展示
    拖动条SeekBar
    信息提示框、对话框
    键盘事件、触摸事件
    时间日期事件处理,长按事件
    图片切换示例
    索引值的应用
    this的应用
    自定义属性应用1
    自定义属性应用
  • 原文地址:https://www.cnblogs.com/sasuke6/p/4737245.html
Copyright © 2011-2022 走看看