获取当前位置需要改plist文件  在plist文件加入   NSLocationWhenInUseUsageDescription  字段 

 

  /**

     初始化一个管理器对象

     */

    locationManager = [[CLLocationManager alloc] init];

    /**

     *  设置代理

     */

    locationManager.delegate = self;

    locationManager.desiredAccuracy = kCLLocationAccuracyBest;

    /**

     *  设置移动多远来获取一次请求

     */

    locationManager.distanceFilter = 1000.0f;

    

    /**

     *  判断版本

     *

     *  @param requestWhenInUseAuthorization

     *

     *  @return ios7以上需要写此方法来获取当前位置

     */

    if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {

        

        [locationManager requestWhenInUseAuthorization];

    }

    

    /**

     *  开始获取当前位置

     */

    [locationManager startUpdatingLocation];

    

 

posted on 2016-06-12 23:19  Yevgeni  阅读(229)  评论(0编辑  收藏  举报