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()

            

        }

  • 相关阅读:
    [Codeforces 140C] New Year Snowmen
    [Codeforces Round511C] Enlarge GCD
    [BZOJ 1251] 序列终结者
    [NOIP 2016] 愤怒的小鸟
    [POJ 1860] Currency Exchange
    [ZJOI 2006] 书架
    [NOIP 2010] 引入入城
    [NOI 2014] 起床困难综合征
    用C语言实现中文到unicode码的转换
    strdup与strndup
  • 原文地址:https://www.cnblogs.com/scaptain/p/4002659.html
Copyright © 2011-2022 走看看