我正在做一个应用程序。我正在使用下面的CLLOcationmanager
。
[self performSelectorOnMainThread:@selector(findlocation:) withObject:nil waitUntilDone:NO];
-(void)findlocation:(id)sender
{
//NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init];
locationManager=[[CLLocationManager alloc]init];
locationManager.delegate=self;
locationManager.distanceFilter=0.3f;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSLog@"%@",newlocation.timestamp];
}
我想每隔0.3米更新一次位置。但是这个委托方法不会针对该距离触发。在[self performSelectorOnMainThread:@selector(findlocation:) withObject:nil waitUntilDone:NO];
我的剩余流程正在运行之后。
答案 0 :(得分:0)
我认为这可能会对你有所帮助。您需要使用经度和纬度调整距离
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
MKCoordinateRegion region = { { 0.0f, 0.0f }, { 0.0f, 0.0f } };
region.center = newLocation.coordinate;
region.span.longitudeDelta = 0.15f;
region.span.latitudeDelta = 0.15f;
[self.mapView setRegion:region animated:YES];
}
以上代码使用0.15度(0.15 * 111 Km)。
或者尝试使用distanceFilter“。使用distanceFilter可以过滤掉那种无关的动作。