首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏全栈程序员必看

    CLLocation定位

    NSObject { public static let `default` = CLLocationTool.init() /// 定位 var locationManager: CLLocationManager = CLLocationManager() var currLocation: CLLocation! () if (CLLocationManager.locationServicesEnabled() == false) || (status == .denied) || (status CLError { let status = CLLocationManager.authorizationStatus() if (CLLocationManager.locationServicesEnabled (“空”, “空”, “空”) } } } func locationManager(_ manager: CLLocationManager,

    84520编辑于 2022-09-17
  • 来自专栏ppppy_oschina

    iOS原生定位和反编码

    导入头文件 #import <CoreLocation/CoreLocation.h> @property (nonatomic, strong) CLLocationManager *lcManager 开始请求定位 if ([CLLocationManager locationServicesEnabled]) { // 创建位置管理者对象 self.lcManager = [[CLLocationManager ]; // 开始更新位置 }else{ //没开启,做其他提醒 } 代理:CLLocationManagerDelegate 代理方法: ` -(void)locationManager:(CLLocationManager CLPlacemark *place = [placemarks firstObject]; //place包含了地理信息 }]; } -(void)locationManager:(CLLocationManager

    67430编辑于 2022-11-15
  • 来自专栏python3

    疯狂ios讲义之使用CoreLocati

    如果定位管理器支持heading属性,那么CLLocationManager的headingAvailable属性将会返回“YES”。 使用CLLocationManager获取设备方向与获取移动距离的步骤基本相似,只是此时不是检测位置移动,而是检测方向改变。 使用CLLocationManager获取设备方向的步骤如下。 创建CLLocationManager对象,该对象负责获取定位相关信息。并为该对象设置一些必要的属性。 为CLLocationManager指定delegate属性,该属性值必须是一个实现CLLocationManagerDelegate协议的对象。 调用CLLocationManager的startUpdatingHeading方法获取方向信息。获取方向结束时,可调用stopUpdatingHeading方法结束获取方向信息。

    1.2K00发布于 2020-01-08
  • 来自专栏sktj

    IOS 定位CoreLocation

    CoreLocation 2 class ViewController:UIViewController,CLLocationManagerDelegate 3 var locationManager:CLLocationManager 7 // Do any additional setup after loading the view, typically from a nib. 8 9 locationManager = CLLocationManager label.numberOfLines = 2 16 label.backgroundColor = UIColor.brown 17 self.view.addSubview(label) 18 19 if CLLocationManager.authorizationStatus { 20 locationManager.requestAlwaysAuthorization() 21 } 22 } 23 func locationManager(_ manager: CLLocationManager default: 29 manager.startUpdatingLocation() 30 break; 31 } 32 } 33 func locationManager(_ manager: CLLocationManager

    52820发布于 2019-07-10
  • 来自专栏码农的生活

    IOS 定位CoreLocation代码

    来确定位置信息 并且需要实现CLLocationManagerDelegate协议 1.首先添加类库CoreLocation 2.需要实现协议CLLocationManagerDelegate 设置全局的CLLocationManager 就是gps位置管理器 打开 关闭 获取gps经纬度 CLLocationManager *gpsManager; 3.开始定位 -(void)startLocation{ //0.判断 [CLLocationManager locationServicesEnabled]) { NSLog(@"没有定位 或者没有打开定位"); } //1.创建一个定位对象 manager = [[CLLocationManager alloc]init]; //设置GPS的精确度 manager.desiredAccuracy = kCLLocationAccuracyBest stopUpdatingLocation]; manager = nil; } #pragma mark - 每次GPS更新位置信息都会被触发 -(void)locationManager:(CLLocationManager

    79820发布于 2021-10-29
  • 来自专栏全栈程序员必看

    iOS开发-用户定位获取-CoreLocation的实际应用-CLLocationManger获取定位权限-CLLocation详细使用方式

    本期内容: CLLocationManager申请定位权限 CLLocationManager获取用户定位 CLLocation详细使用,定位数据处理 GPX虚拟定位文件的使用以及模拟器定位使用 --- - CLLocationManager 定位管理器 简介:CLLocationManager是用于启动和停止向App获取位置相关的事件的对象。 ---- CLLocationManager申请定位权限 那我们就开始了,首先要去项目的target里设置info.plist文件字段(苹果的隐私安全需求,不添加是不允许使用的),如下图标注的三个字段: 完成了以上步骤,我们就可以获得权限了,然后我们开始去获得定位 ---- CLLocationManager获取用户定位 CLLocationManager在获取定位的时候是通过代理方法实现的,该方法包装了类型为 和CLLocationManager很像是吧?官方有话说:CLLocation对象包含设备的地理位置和高度,以及指示这些测量值的准确性和收集时间的值。

    5.6K20编辑于 2022-09-17
  • 来自专栏進无尽的文章

    扒虫篇 - 定位授权前地图定位造成的黑屏

    解决方案 在系统的AppDegate 类中申请系统的定位,使地图在定位之前获取到系统的定位权限,即可解决这个系统级别的Bug 代码 [CLLocationManager locationServicesEnabled CLLocationManagerDelegate的locationManager:didFailWithError:方法去检测: 在代理方法中查看权限是否改变 - (void)locationManager:(CLLocationManager kCLAuthorizationStatusRestricted: NSLog(@"Restricted"); break; default: break; }} /** 第一次执行以下语句时会有系统定位权限弹框弹出 */ CLLocationManager *manager = [[CLLocationManager alloc] init]; [manager requestAlwaysAuthorization];//一直获取定位信息 [manager requestWhenInUseAuthorization];//使用的时候获取定位信息 权限弹框一闪而过的问是CLLocationManager的实例是局部变量在方法中被释放了

    1.2K20发布于 2018-09-12
  • 来自专栏iOS逆向与安全

    iOS小技能:授权检测(引导权限开启,监听权限变化执行回调事件。)

    的授权状态: [CLLocationManager authorizationStatus kCLAuthorizationStatusNotDetermined / }else if (status == kCLAuthorizationStatusNotDetermined){//用户尚未对该应用程序作出选择,安装之后第一次使用 CLLocationManager 执行允许之后的定位操作 block(nil); } return YES; } 监听权限变化执行回调事件 - (CLLocationManager *)locationMan { if(_locationMan == nil){ _locationMan = [CLLocationManager new]; } #pragma mark - ******** CLLocationManagerDelegate - (void)locationManagerDidChangeAuthorization:(CLLocationManager

    4K40编辑于 2022-08-22
  • 来自专栏一“技”之长

    IOS定位服务的应用 原

    IOS8中CLLocationManager新增的两个新方法: - (void)requestAlwaysAuthorization; - (void)requestWhenInUseAuthorization * manager = [[CLLocationManager alloc]init];//初始化一个定位管理对象     [manager requestWhenInUseAuthorization]  *)manager didUpdateLocations:(NSArray *)locations{     NSLog(@"%@",locations); } @end CLLocationManager - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading; 航向信息更新后调用的方法 - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error; 定位异常时调用的方法 四

    1.2K20发布于 2018-08-15
  • 来自专栏王大锤

    iOS地理围栏技术的应用

    而区域监测我们有3种方法完成: 1,oc自有的,利用CLLocationManager监测若干CLCircularRegion区域 2,高德地图旧版地理围栏,利用AMapLocationManager监测若干 其实是对CLLocationManager进行简单封装,用法也和CLLocationManager基本一致 3,高德地图新版地理围栏,有个专门进行区域监测的管理类AMapGeoFenceManager, -(CLLocationManager *)locationM { if (! CLLocationManager换成AMapLocationManager,CLCircularRegion换成AMapLocationCircleRegion。文章结尾会有demo下载。 看了高德的注释也让我明白了CLLocationManager监测区域的实现,赞一个。DEMO地址:http://lbs.amap.com/api/ios-location-sdk/download/

    2.5K60发布于 2018-05-17
  • 来自专栏DannyHoo的专栏

    定位1

    https://blog.csdn.net/u010105969/article/details/51686102 需要调用 CLLocationManager requestAlwaysAuthorization @interface里:     CLLocationManager *locationManager; 2. 初始化:     locationManager = [[CLLocationManager alloc] init]; 3.

    71120发布于 2018-09-13
  • 来自专栏xx_Cc的学习总结专栏

    iOS-世界那么大,CoreLocation带你去看看

    创建CLLocationManager管理者对象。 遵循代理,并实现代理方法。 设置获取用户前后台定位授权 开始定位。 三. CLLocationManager的使用 学习CLLocationManager可以分为三个部分。1.定位 2.手机朝向 3.区域监听 1. CLLocationManager -- 定位 先通过一个简单例子看一下 #import "ViewController.h" #import <CoreLocation/CoreLocation.h > @interface ViewController ()<CLLocationManagerDelegate> @property(nonatomic,strong)CLLocationManager LocationManager是将CLLocationManager由代理向block的封装转换。

    1.8K90发布于 2018-05-10
  • 来自专栏大宇笔记

    swift 定位封装一句话使用

    LocationManager = LocationManager() private override init() { } var manager:CLLocationManager func creatLocationManager() -> LocationManager{ manager = CLLocationManager() //设置定位服务管理器代理 resultBack:@escaping locationCallBack){ self.callBack = resultBack if CLLocationManager.locationServicesEnabled } extension LocationManager:CLLocationManagerDelegate { func locationManager(_ manager: CLLocationManager manager.stopUpdatingLocation() LonLatToCity() } } func locationManager(_ manager: CLLocationManager

    1.6K20发布于 2019-01-15
  • 来自专栏全栈程序员必看

    iOS关于地图定位基础(二)[通俗易懂]

    (一、定位实现&监听方向)那么我们先来看看这个代理方法: // 通过位置管理者一旦定位到位置,就会一直调用这个代理方法 - (void)locationManager:(CLLocationManager 我们看看以下代码: #pragma mark - CLLocationManagerDelegate - (void)locationManager:(CLLocationManager *)manager * clManager; @end @implementation HWCompass #pragma mark - lazy - (CLLocationManager *)clManager * clManager; @end @implementation ViewController - (CLLocationManager *)clManager { if (! * clManager; @end @implementation ViewController - (CLLocationManager *)clManager { if (!

    1.4K20编辑于 2022-09-17
  • 来自专栏mukekeheart的iOS之旅

    iOS学习——自动定位

    一 定位参数的配置    定位参数的配置主要是通过系统的定位管理器CLLocationManager进行配置,参数配置的几个要点主要是设置代理,设置寻址精度,然后开启定位。 当然,这些参数的配置的前提是我们的手机已经对我们的项目进行了地理位置的授权,所以我们再配置之前需要对当前定位权限进行判断,通过 [CLLocationManager locationServicesEnabled [self configLocation]; } - (void)configLocation{ self.place = @""; //判断定位权限是否打开 if ([CLLocationManager #pragma mark - CLLocationManagerDelegate //定位成功的回调,在这里我们配置我们的位置信息 -(void)locationManager:(CLLocationManager @"":placeMark.thoroughfare]; } } }]; } //定位失败时调用 - (void)locationManager:(CLLocationManager

    1.2K100发布于 2018-03-26
  • 来自专栏移动开发面面观

    iOS学习笔记——LBS

    实践 CLLocationManager iOS为我们提供了位置服务类CLLocationManager。 CoreLocation.h> @interface LocationManager : NSObject<CLLocationManagerDelegate> @property (strong,strong ) CLLocationManager void)getLocation; @end LocationManager.m #import "LocationManager.h" @implementation LocationManager CLLocationManager _locationManager.delegate = self; #pragma mark - 定位失败 -(void)locationManager:(CLLocationManager *)manager NSString *_strLongitude;//维度 - (void)getLocation{ printf("OC get location\n"); if ([CLLocationManager

    2.2K30发布于 2018-07-03
  • 来自专栏Guangdong Qi

    iOS-定位

    *及以前:****- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus 自苹果X后,如果在子线程开始定位,会有UI不在主线程调用的警告,直接屏蔽或者忽略即可,不影响正常使用; //前置步骤:创建定位管理类CLLocationManager,配置定位参数 //开始定位 - ; } } } } //请求定位权限, - (void)requestLocationAuthorizationIfNeed:(CLLocationManager ; } } } 5、定位权限状态变更 //iOS13及以前版本回调 - (void)locationManager:(CLLocationManager *)manager authorizationStatus]]; } //iOS14及以后版本回调 - (void)locationManagerDidChangeAuthorization:(CLLocationManager

    2K20发布于 2021-11-24
  • 来自专栏学海无涯

    iOS开发之定位

    一、模块与常见类 定位所包含的类都在CoreLocation模块中,所以必须导入import CoreLocation CLLocation:表示某个位置的地理信息,比如经纬度、海拔等 CLLocationManager CLPlacemark:位置信息,包含的信息如国家、城市、街道等 CLLocationManagerDelegate:定位代理,不管是定位成功与失败,都会有相应的代理方法回调 具体的工作流程 (1)CLLocationManager lazy var locationManager:CLLocationManager = CLLocationManager() override func viewDidLoad( extension ViewController : CLLocationManagerDelegate{ //定位成功 func locationManager(_ manager: CLLocationManager self.locationManager.stopUpdatingLocation() } //定位失败 func locationManager(_ manager: CLLocationManager

    1.9K10发布于 2019-03-21
  • 来自专栏joealzhou

    iOS区域监控(地理围栏)

    一、导入框架 import CoreLocation 二、初始化CLLocationManager locationManager = CLLocationManager() locationManager.delegate MARK: - 区域监控代理方法 extension AppLocationManager { /// 进入区域 func locationManager(_ manager: CLLocationManager CLRegion) { debugPrint("进入区域") } /// 离开区域 func locationManager(_ manager: CLLocationManager CLRegion) { debugPrint("离开区域") } /// 请求某个区域的状态 func locationManager(_ manager: CLLocationManager /// 开启区域定位 func regionWatch() { if CLLocationManager.isMonitoringAvailable(for: CLCircularRegion.self

    1.9K21发布于 2019-08-23
  • 来自专栏iOS开发攻城狮的集散地

    iOS 仿系统指南针

    + 30)]; lineView.backgroundColor = [UIColor whiteColor]; [self addSubview:lineView]; } 2、利用CLLocationManager self.locationManager.allowsBackgroundLocationUpdates = YES; //判断定位设备是否能用和能否获得导航数据 if ([CLLocationManager locationServicesEnabled]&&[CLLocationManager headingAvailable]){ [self.locationManager startUpdatingLocation #pragma mark - CLLocationManagerDelegate //获得地理和地磁航向数据,从而转动地理刻度表 -(void)locationManager:(CLLocationManager // 定位成功之后的回调方法,只要位置改变,就会调用这个方法 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations

    1.5K50发布于 2018-05-22
领券