zoukankan      html  css  js  c++  java
  • CoreLocation简单应用

    1、获取locationManager

    let locationManager: CLLocationManager = CLLocationManager()

    2、设置locationManager的精度

    locationManager.desiredAccuracy = kCLLocationAccuracyBest

    3、如果是ios8需要

    locationManager.requestAlwaysAuthorization()

    4、开始监听数据的更新

    locationManager.startUpdatingLocation()

    5、添加locationManagerDelegate的回调函数,并将经纬度打出

        func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!){

            var location:CLLocation = locations[locations.count - 1] as CLLocation

            if(location.horizontalAccuracy > 0){

                println("(location.coordinate.latitude)")

                println("(location.coordinate.longitude)")

                           

            }

    6、设置locationManager的代理

    locationManager.delegate = self

    7、locationManager错误处理

    func locationManager(manager: CLLocationManager!, rangingBeaconsDidFailForRegion region: CLBeaconRegion!, withError error: NSError!){

                println(error)

        }

    8、关闭数据更新

    locationManager.stopUpdatingLocation()

            

        }

  • 相关阅读:
    docker中安装ssh服务
    JStorm第一个程序WordCount详解
    centos6.7 安装Docker
    mysql 自连接查询数据
    display属性
    如何书写高效的css样式
    link和@import的区别
    div+css命名规则
    MATLAB的一些小技巧
    高等工程数学 线性规划部分 作业
  • 原文地址:https://www.cnblogs.com/scaptain/p/4002659.html
Copyright © 2011-2022 走看看