swift ios8 定位
来源:互联网 发布:ecshop换模板sql查询 编辑:程序博客网 时间:2024/06/04 18:46
由于iOS8定位机制的变化
需要在pist添加字段
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
这2个字段都是Boolean类型 设为YES
导入CoreLocation FrameWork
代码中
import CoreLocation
lazy var locationManager : CLLocationManager = { var lm = CLLocationManager() lm.delegate = self lm.requestAlwaysAuthorization() lm.desiredAccuracy = kCLLocationAccuracyBest lm.distanceFilter = kCLDistanceFilterNone return lm }()
func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) { switch status { case CLAuthorizationStatus.NotDetermined: if locationManager.respondsToSelector(Selector("requestWhenInUseAuthorization")) { locationManager.requestWhenInUseAuthorization() } default: println("") } } func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { let location = locations.last as CLLocation println("lat : \(location.coordinate.latitude) lng : \(location.coordinate.longitude)") } //MARK:生命周期 override func viewWillAppear(animated: Bool) { super.viewWillAppear(animated) locationManager.startUpdatingLocation() } override func viewWillDisappear(animated: Bool) { super.viewWillDisappear(animated) locationManager.stopUpdatingLocation() }
0 0
- swift ios8 定位
- Swift IOS8
- IOS8定位
- iOS8定位
- IOS8定位
- iOS8定位
- IOS8 定位
- 定位城市+iOS8 定位问题
- swift,demo,ios8
- ios8 notification in swift
- iOS8-Swift开发教程
- swift iOS8 XIB 问题
- iOS8 定位问题
- ios8 定位问题解决
- iOS8 定位新增功能
- iOS8 定位问题
- iOS8定位服务
- iOS8 定位失败问题
- 10进制数转2进制数
- SSH框架中struts开发环境搭建
- 学习Golang语言(2)
- 想的太复杂
- android 四大组件之BroadcaseReceiver
- swift ios8 定位
- Android点击事件的4种写法
- 记录学习的过程
- Windows 8.1, UEFI 模式下U盘安装Ubuntu 14.10 或者 Opensuse 13.02 双系统
- 常见随机分布的数学期望及方差
- 黑马程序员——杂记——天道酬勤
- 原来Github上的README.md文件这么有意思——Markdown语言详解
- Unity新UI系统概述——Animation Integration
- source insight使用技巧