Core Location的使用
来源:互联网 发布:内存卡数据恢复 编辑:程序博客网 时间:2024/05/24 15:36
1.import CoreLocation
2.Info.plist中写入
Privacy - Location Usage Description 我们需要使用你的地理位置信息
NSLocationWhenInUseUsageDescription 我们需要使用你的地理位置信息
3.初始化并遵守CLLocationManagerDelegate
let locationManger:CLLocationManager = CLLocationManager()
4.判断定位服务是否开启并设置属性
判断定位服务是否开启
if CLLocationManager.locationServicesEnabled() {
print("开启")
}else{
print("未开启")
}
locationManger.delegate = self;
locationManger.requestWhenInUseAuthorization() //请求授权,之前要在infoPlist中设置
5.开始更新location
locationManger.startUpdatingLocation()
6.停止更新location
locationManger.stopUpdatingLocation()
7.代理方法
位置发生变化时执行
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){
}
导航方向发生变化时执行
func locationManager(manager: CLLocationManager, didUpdateHeading newHeading: CLHeading){
}
进入某个区域是执行
func locationManager(manager: CLLocationManager, didEnterRegion region: CLRegion){
}
走出某个区域时执行
func locationManager(manager: CLLocationManager, didExitRegion region: CLRegion){
}
更多方法请查看官方文档
- Core Location的使用
- 使用Core Location
- ios-使用Core Location定位
- Core Location和MapKit的一些简单使用
- 关于 Core Location 的笔记
- Core Location
- Core Location定位和MapKit视图使用
- ios-使用Core Location框架定位
- iOS定位服务Core Location使用详解
- 如何使用Core Location获取当前的位置和GPS的坐标呢?
- Android Location的使用
- window.location的使用
- IOS学习之Core Location定位和MapKit视图使用
- iOS8之在Today Extension中使用Core Location
- Core Location 简述
- IOS Core Location
- Core Location之指南针
- Core Location Framework学习
- 限制输入文字长度最好的方法
- Cocoapods的详细使用教程 (安装/使用/删除/注意)
- rtc相关博客
- SoapUI基本使用
- 编码,解码,乱码,问题详解
- Core Location的使用
- 数组与内存的控制
- python对文件的指定行写入
- NSUserDefaults数据存储总结
- HttpServer的简单实现_Java
- #define #if #ifdef #ifndef 作用和区别
- 使用AFNetWorking请求错误
- MapReduce 调优基本思路
- 实验:一个进程到底能创建多少线程?