[iOS][Background]更新地图插脚|绘制线

[iOS][Background]更新地图插脚|绘制线,ios,objective-c,map,annotations,line,Ios,Objective C,Map,Annotations,Line,Hy:) 我正在尝试在后台更新设备(iPhone)的位置,它与模拟器一起工作(注释只在后台添加) 但是当我用我的iPhone进行测试时,它不起作用,我在最后一个位置(在后台之前)和激活的位置之间有一条线 编码呢 我做了一个列表测试,当应用程序在后台时,当应用程序再次激活时,我加载记录的位置列表。(使用模拟器) 谢谢你的帮助;) 通过在后台创建位置列表来添加批注是一个更好的选择。当应用程序位于后台时,无法管理uielements。为此,您应该在应用程序位于后台时添加数组中的所有位置。如何设置CLL

Hy:)

我正在尝试在后台更新设备(iPhone)的位置,它与模拟器一起工作(注释只在后台添加)

但是当我用我的iPhone进行测试时,它不起作用,我在最后一个位置(在后台之前)和激活的位置之间有一条线

编码呢

我做了一个列表测试,当应用程序在后台时,当应用程序再次激活时,我加载记录的位置列表。(使用模拟器)


谢谢你的帮助;)

通过在后台创建位置列表来添加批注是一个更好的选择。当应用程序位于后台时,无法管理uielements。为此,您应该在应用程序位于后台时添加数组中的所有位置。

如何设置CLLocationManager?
-(void)设置{self.locationManager=[CLLocationManager new];self.locationManager.delegate=self;self.locationManager.desiredAccuracy=kCLLocationAccuracyBest;self.IsUpdateingLocation=NO;}
现在可以工作了,我必须在主线程[self-performSelectorOnMainThread:@selector(handleAddLocations)上添加位置,对象为:nil waitUntilDone:NO];此外,模拟器工作正常,但我的手机的精确度很差,比如200米。你知道吗?对于位置管理器,你应该将精确度设置为最佳,然后才能得到准确的结果。
    - (void)handleAddLocations {
        NSLog(@"%s | %@", __PRETTY_FUNCTION__, self.locationBackgroundList);

        if ([self.locationBackgroundList count] > 0) {
            for (CLLocation *backgroundLocation in self.locationBackgroundList) {

                if (YES){
                    LocAnnotation* annotation = [[LocAnnotation alloc] initWithCoordinate:backgroundLocation.coordinate];
                    NSLog(@"%s %@", __PRETTY_FUNCTION__, [annotation description]);
                    [self.mapView addAnnotation:annotation];
            }

        MKUserLocation *userLocation = [[MKUserLocation alloc] init];
        [userLocation setCoordinate:backgroundLocation.coordinate];

        [self mapView:self.mapView didUpdateUserLocation:userLocation];

         }
        [self.mapView updateConstraints];

        [self.locationBackgroundList removeAllObjects];
        self.locationBackgroundList = [[NSMutableArray alloc] init];
      }
  }