CoreLoation
- (CLLocationManager *)locationManager
{
if (!_locationManager) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.distanceFilter = ;
[_locationManager requestAlwaysAuthorization];//添加这句
}
return _locationManager;
} #pragma mark - CLLocationManagerDelegate - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
debugMethod();
CLLocation *currentLocation = [locations lastObject];
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemarks, NSError *error) {
CLPlacemark *placemark = [placemarks firstObject]; }]; //关闭定位服务
[self.locationManager stopUpdatingLocation];
} #pragma mark - IBAction //定位按钮被点中
- (IBAction)locationBtnDidClick:(id)sender {
debugMethod();
if([CLLocationManager locationServicesEnabled]) {
[self.locationManager startUpdatingLocation];
} else {
[self.tableView makeToast:@"请打开定位服务" duration:1.0 position:@"center"];
}
} info.plist中加入两行:
NSLocationAlwaysUsageDescription : 点击"允许"以开启云买手定位服务
NSLocationWhenInUseDescription : 点击"允许"以开启云买手定位服务
CoreLoation的更多相关文章
- ReactiveCocoa Tutorial
ReactiveCocoa Tutorial – The Definitive Introduction: Part 1/2 ReactiveCocoa教程——明确的介绍:第一部分(共两部分) As ...
- 获取图片的metaData
获取图片的metaData 获取简易的metaData较为容易,以下是测试图: 以下是本人提供的源码: UIImage+MetaData.h // // UIImage+MetaData.h // P ...
随机推荐
- ThinkPHP之验证码的使用
ThinkPHP中已经提供了验证码的生成以及验证的功能.下面介绍如何使用验证码.编程的时候还是采用MVC的方式 View层 <!DOCTYPE html> <html> < ...
- JAVA中的NIO(二)
一.内存文件映射 内存文件映射允许我们创建和修改那些因为太大而不能放入内存中的文件.有了内存文件映射,我们就可以假定整个文件都在内存中,而且可以完全把文件当作数组来访问. package com.dy ...
- iOS---cell-自适应高度
RootViewController: // // RootViewController.m // UI__cell自适应高度 // // Created by dllo on 16/3/15. // ...
- SQL基础知识总结(一)
1.union 和union all 操作符 1)union内部的select语句必须拥有相同的列,列也必须有相似的数字类型.同时,每条select语句中列的顺序相同. union语法(结果集无重复) ...
- Spring 管理数据源
Spring 管理数据源 不管通过何种持久化技术,都必须通过数据连接访问数据库,在Spring中,数据连接是通过数据源获得的.在以往的应用中,数据源一般是Web应用服务器提供的.在Spring中,你不 ...
- PowerDesigner-制作Word导出模版
定制导出模版 当然这不是我们想要的word,下面看如何做一个自定义模版 1. 在工具栏中选择[Report -->Reports],如下图 点击第二个图标创建一个Template,如下图 2. ...
- PowerDesigner-导出表到word
1. 在工具栏中选择[Report -->Reports],如下图 2. 点击第二个图标创建一个Report,如下图 该wizard中有三个信息 Report name Report : Rep ...
- Java基础-JVM内存回收
Sun的JVMGenerationalCollecting(垃圾回收)原理是这样的:把对象分为年青代(Young).年老代(Tenured).持久代(Perm),对不同生命周期的对象使用不同的算法.( ...
- C/C++ 跨平台交叉编译、静态库/动态库编译、MinGW、Cygwin、CodeBlocks使用原理及链接参数选项
目录 . 引言 . 交叉编译 . Cygwin简介 . 静态库编译及使用 . 动态库编译及使用 . MinGW简介 . CodeBlocks简介 0. 引言 UNIX是一个注册商标,是要满足一大堆条件 ...
- Linux中的TUN/TAP设备
今天才发现这家伙...怎么讲...深以为耻.晚上的任务是加深对它的了解,就这么定了. 1. General questions.1.1 What is the TUN ? The TUN is Vi ...