locationManager= [[CLLocationManager alloc] init];//位置管理器
locationManager.desiredAccuracy = kCLLocationAccuracyBest;//精度,设可而止
locationManager.delegate = self;//设置委托
locationManager.distanceFilter = 100.0f;//距离删选器
[locationManager startUpdatingLocation]; //启动位置管理器 #pragma mark -
#pragma mark locationManager
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
//获取所在地城市名
CLGeocoder *geocoder=[[CLGeocoder alloc]init];
[geocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *placemarks,NSError *error)
{
for(CLPlacemark *placemark in placemarks)
{ NSString *str1=[[placemark.addressDictionary objectForKey:@"Name"] substringFromIndex:];
NSLog(@"%@", [NSString stringWithFormat:@"我的位置:%@",str1]);
UITextView *locText = (UITextView*)[self.view viewWithTag:];
}
}];
//map region
[geocoder release];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{ if (error.code == kCLErrorDenied) {
[[[[UIAlertView alloc] initWithTitle:@"错误信息"
message:@"无法获取您的定位信息"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil] autorelease] show];
[locationManager stopUpdatingLocation];
}
}

获取当前位置信息-ios的更多相关文章

  1. 关于微信小程序获取当前位置信息

    小程序开发---获取当前位置信息 一.获取用户地理位置信息 1.配置app.json文件 { "pages": ["pages/index/index"], & ...

  2. iOS项目开发实战——使用CoreLocation获取当前位置信息

    随着基于位置服务LBS和移动互联网的兴起,你的位置是越来越重要的一个信息.位置服务已经是当前的热门应用如微信.陌陌等社交应用的杀手锏.而在iOS开发中,苹果已经给我们提供了一个位置接口.CoreLoc ...

  3. 在Android Studio中使用BaiduMap SDK实时获取当地位置信息

    配置BaiduMap 环境 1.在百度API中新建自己的一个APP包名和APP名需要注意和自己Android Studio 中的包名和APP名保持一致: 2.百度地图中还需要填写一个SHA1 数字签名 ...

  4. Android初级教程获取手机位置信息GPS与动态获取最佳方式

    简单介绍一下gps定位的操作. 主要是靠locationmanger这个api完成的一些操作:通过获取这个实例,然后调用它的requestLocationUpdates方法进行注册.传入的参数分别有以 ...

  5. C# 图像处理:获取鼠标位置信息(全局)

    Point ms = Control.MousePosition; //获取鼠标位置 this.label2.Text = string.Format("{0}:{1}", ms. ...

  6. 获取元素位置信息和所占空间大小(via:js&jquery)

    工作中有一个很常见的需求,hover或者click某元素后,在该元素旁边出现弹框,主要就是获取该元素的位置坐标以及元素所占区块的大小.最近工作中就遇到了,发现js和jquery的实现方法有很大的区别, ...

  7. Android GPS获取当前位置信息

    package com.example.gpstest; import org.apache.http.util.LangUtils; import android.content.Context; ...

  8. ios 定位获取当前位置信息

    啊,倦怠的人生啊~~ 什么事情都没做一眨眼就2点半了啊!!赶紧爬起来写博客啊. 诸位看官会鄙视我么,表示我真心不是把这当技术文章写的啊. 啊,下午我们来第二篇.获取地理位置信息.嗯嗯,秘籍上说叫逆向地 ...

  9. windowsphone中获取手机位置信息

    首先在界面中加入一个textblock控件以显示信息 using System; using System.Collections.Generic; using System.IO; using Sy ...

随机推荐

  1. 请帮我看看这个页面,红色部份如何改才能保存到ACCess数据库中

    <% if session("shiwei_username")="" then %> <script language="java ...

  2. Assembly 'Microsoft.Office.Interop.Excel

    编译的时候报错,都无法通过编译: Assembly 'Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, Public ...

  3. Property type 'id<tabBarDelegate>' is incompatible with type 'id<UITabBarDelegate> _Nullable' inherited from 'UITabBar'

    iOS报错:Property type 'id' is incompatible with type 'id _Nullable' inherited from 'UITabBar' 如图: 可能原因 ...

  4. OREACLE 数据库建表 添加判断表是否存在 不存在则新建

    declare  cnt number; begin   ---查询要创建的表是否存在   select count(*)into cnt from user_tables where table_n ...

  5. Ignatius and the Princess I

    算法:搜索+优先队列+(递归输出结果) The Princess has been abducted by the BEelzebub feng5166, our hero Ignatius has ...

  6. 基础知识 mfc

    句柄 资源的标示  图标句柄(HICON) 光标句柄(HCURSOR) 窗口句柄(HWND) 类似于指针 wm_keydown表示键盘上的按键按下了数值 WPARAM ||LPARAM  两个整形数据 ...

  7. java学习笔记(10) —— ActionContext、ServletActionContext、ServletRequestAware用法

    核心思想 1.ActionContext HttpServletRequest getAttribute setAttribute ActionContext get put //ActionCont ...

  8. Microsoft Anti-Cross Site Scripting Library V4.2 下载地址

    概述 微软反跨站脚本库V4.2(AntiXSS V4.2)是一种编码库,旨在帮助开发人员保护他们的ASP.NET基于Web的应用程序免受XSS攻击.它不同于编码库,因为它使用的白名单技术-有时也被称为 ...

  9. dede 日期的所有格式

    [field:pubdate function=strftime('%d',@me)/] 日 [field:pubdate function=strftime('%d日',@me)/] - [fiel ...

  10. Go Cookie 练习

    package main import ( "io" "log" "net/http" ) func main() { http.Handl ...