• didUpdateLocations代替didUpdateToLocation


    与iOS6的苹果didUpdateLocations代替didUpdateToLocation的释放。任何人都可以解释如何didUpdateLocations?

    1. 我以下的委托,以获得最后一个位置?

    - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation

    上述委托弃用的iOS 6。现在,下面应该

    - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations

    为了获得最后的位置,只需获取数组的最后一个对象:

    [locations lastObject]

    换句话说,[locations lastObject](新代表)等于newLocation(老代表)。

     
    2. 它给你的对象数组来访问最后一个位置你

    [locations lastObject]

    由此

    - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations

    3. 

    这里没有其他的答案中解释了为什么有一个位置数组,以及如何将新didUpdateLocations:提供的数组。 贬低的目的locationManager:didUpdateToLocation:fromLocation:和发送位置一个NSArray,而不是在后台运行时降低功耗。 与iPhone 5开始时 CodeGo.net,GPS芯片具有存储位置的一段,然后传送在一次数组中的他们所有的能力。这被称为延迟的位置更新。这允许主CPU进入睡眠状态,而在背景中较长的时间。的iOS不具备启动主CPU的每个位置更新时,CPU可以睡,而GPS芯片集的位置。 您可以检查这个deferredLocationUpdatesAvailable方法。如果可用,您可以启用allowDeferredLocationUpdatesUntilTraveled:timeout:方法。条件适用,看到这个答案的细节。

     

    4. 如果你支持的iOS 5和6,你应该叫

    - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations,

    从旧

    - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation

    函数,通过建立的位置的数组。

  • 相关阅读:
    C++中对C的扩展学习新增语法——lambda 表达式(匿名函数)
    C++中对C的扩展学习新增语法——内联函数以及函数参数
    C++中对C的扩展学习新增语法——For循环以及AUTO类型
    C++中对C的扩展学习新增语法——强枚举
    C++中对C的扩展学习新增语法——引用
    C++中对C的扩展学习新增语法——const
    C++中对C的扩展学习新增语法——强制类型转换
    3. Longest Substring Without Repeating Characters
    2. Add Two Numbers
    策略模式
  • 原文地址:https://www.cnblogs.com/ChouDanDan/p/5364575.html
Copyright © 2020-2023  润新知