【发布时间】:2013-04-28 16:07:29
【问题描述】:
喂 :)
我正在尝试在后台更新设备 (iPhone) 的位置,它适用于模拟器 http://grab.by/meLq(注释仅在后台添加)。
但是当我用我的 iPhone 进行测试时,它不起作用,我在最后一个位置(在后台之前)和激活时的位置之间有一条线。
编码呢?
当应用程序处于后台并且当应用程序再次变为活动状态时,我进行了创建列表的测试,我加载了记录的位置列表。 (使用模拟器)
- (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];
}
}
感谢您的帮助;)
【问题讨论】:
-
你是如何设置 CLLocationManager 的?
-
- (void)setup { self.locationManager = [CLLocationManager new]; self.locationManager.delegate = self; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; self.isUpdatingLocation = NO; }
标签: ios objective-c map annotations line