美文网首页
定位时防止代理方法didUpdateLocations执行多次

定位时防止代理方法didUpdateLocations执行多次

作者: 卡布哒Q | 来源:发表于2018-03-09 10:41 被阅读0次
    • (void)locationManager:(CLLocationManager *)manager
      didUpdateLocations:(NSArray<CLLocation *> *)locations {
      [manager stopUpdatingLocation];
      // 将代理对象置为空,防止多次调用
      manager.delegate = nil;
      CLLocation *lastLocation = [locations lastObject];
      }
      定位成功之后,将代理对象置为空,如果没有委托引用:代理对象无法find您的didUpdateLocations方法

    ******开始定位时,将manager的代理对象重置

    相关文章

      网友评论

          本文标题:定位时防止代理方法didUpdateLocations执行多次

          本文链接:https://www.haomeiwen.com/subject/ljlpfftx.html