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 ...
随机推荐
- openwrt的路由器重置root密码
家里路由器刷了openwrt,结果长期没登录,忘了root密码. 很容易就找到了这里介绍的办法 http://www.openwrt.org.cn/bbs/thread-12327-1-1.html ...
- 第四十课:CSS3 transition详解
W3C中对transition是这样描述的:允许css的属性值在一定的时间内平滑的过渡,也就是说,以动画的效果改变css的属性值. transition主要包含4个属性值:transition-pro ...
- jQuery使用之(二)设置元素的样式
css是页面不能分隔的部分,jQuery中也提供了一些css相关的实用的办法.前面章节中有使用过 addClass()为元素添加css样式风格.本节主要介绍jQuery如何设置页面的样式风格.包括添加 ...
- c# 通过反射获取私有方法
class Program { static void Main(string[] args) { //通过反射来调私有的成员 Type type = typeof(Person); //Bindin ...
- centos 6.5下安装mysql+nginx+redmine 3.1.0 笔记
centos 6.5下安装mysql+nginx+redmine 3.1.0 笔记 目录[-] 过程 1.安装RVM 2.利用rvm安装 Ruby 1.9.3 并设为默认 3.安装rails 4.安装 ...
- 【RSYSLOG】rsyslog作为日志采集器安装配置说明
RSYSLOG is the rocket-fast system for log processing. About 由于环境基于CentOS 6.7 x64,rsyslog本身就是OS的组件,由于 ...
- 在CentOS上装 ElasticSearch
参考官方文档:Install Elasticsearch with RPM ElasticSearch依赖Java,所以需要先安装Java: 到Oracle官网找到下载链接 http://www.or ...
- zoj3888 找第二大
题目简化后最终要求的就是第二大的数.但是由于数据较大,不能直接求.可以先预处理,求出所有情况. #include<stdio.h> #include<string.h> #in ...
- sphinx在c#.net平台下使用(一)
Sphinx是由俄罗斯人Andrew Aksyonoff开发的一个可以结合MySQL,PostgreSQL全文检索引擎.意图为其他应用提供高速.低空间占用.高结果 相关度的全文搜索功能.是做站内全文搜 ...
- struts2中把action中的值传递到jsp页面的例子
例子: RegistAction的代码: package com.wss.action; import javax.servlet.http.HttpServletRequest; import or ...