代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
ObjC
】
如何实现获取当前定位信息
作者:
茶壶
/ 发布于
2015/6/29
/
1330
// // ViewController.m // LocationDemo // // Created by LaughingZhong on 14/11/12. // Copyright (c) 2014年 Laughing. All rights reserved. // #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize myLocationManager,myGeocoder,myLocation; - (void)dealloc { self.myLocationManager = nil; self.myLocation = nil; self.myGeocoder = nil; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. if ([CLLocationManager locationServicesEnabled]) { self.myLocationManager = [[CLLocationManager alloc] init]; [self.myLocationManager setDelegate:self]; self.myLocationManager.desiredAccuracy = kCLLocationAccuracyBest; self.myLocationManager.distanceFilter = 1.0; // [self.myLocationManager requestAlwaysAuthorization]; [self.myLocationManager requestWhenInUseAuthorization]; [self.myLocationManager startUpdatingLocation]; }else { NSLog(@"Location services are not enabled"); } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - #pragma mark CLLocationManagerDelegate - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { NSLog(@"locations is %@",locations); CLLocation *location = [locations lastObject]; self.myGeocoder = [[CLGeocoder alloc] init]; [self.myGeocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { if(error == nil && [placemarks count]>0) { CLPlacemark *placemark = [placemarks objectAtIndex:0]; NSLog(@"name = %@",placemark.name); NSLog(@"Country = %@", placemark.country); NSLog(@"Postal Code = %@", placemark.postalCode); NSLog(@"locality = %@", placemark.locality); NSLog(@"subLocality = %@", placemark.subLocality); NSLog(@"address = %@",placemark.name); NSLog(@"administrativeArea = %@",placemark.administrativeArea); NSLog(@"subAdministrativeArea = %@",placemark.subAdministrativeArea); NSLog(@"ISOcountryCode = %@",placemark.ISOcountryCode); NSLog(@"thoroughfare = %@", placemark.thoroughfare); NSLog(@"subThoroughfare = %@",placemark.subThoroughfare); [label setText:[NSString stringWithFormat:@"address is: %@",placemark.name]]; } else if(error==nil && [placemarks count]==0){ NSLog(@"No results were returned."); } else if(error != nil) { NSLog(@"An error occurred = %@", error); } }]; [self.myLocationManager stopUpdatingLocation]; } - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { NSLog(@"reverse geocoder error: %@", [error description]); } @end
试试其它关键字
定位信息
同语言下
.
根据生日计算星座
.
精简的实现一个内存池
.
iOS索引搜索核心代码
.
iOS 搜索框
.
文件操作
.
UIWebView 加载本地网页
.
取消导航条对视图的影响
.
利用终端显示 隐藏文件
.
更改导航条背景颜色
.
iOS 字体斜体
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
茶壶
贡献的其它代码
(
9
)
.
毛玻璃效果
.
整数N随机分成n份
.
如何实现获取当前定位信息
.
获取相册的所有相片
.
plist基本操作
.
获取客户端真实ip地址
.
仿async的 并行执行和序列执行函数
.
二元搜索
.
图的遍历
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3