我需要些帮助。
当我打开地图时,我必须重新定位我的当前位置,并将其发送到服务器以获取所有其他引脚。(就像附近的东西)。
我设定:
- (void)viewDidLoad
{
// if location services are on
if([CLLocationManager locationServicesEnabled])
{
// if location services are restricted do nothing
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied ||
[CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted )
{
NSLog(@"Location tracking disabled.");
}
else
{
NSLog(@"all ok");
self.locationMeneger = [[CLLocationManager alloc] init];
self.locationMeneger.delegate = self;
[self.locationMeneger setDistanceFilter:kCLDistanceFilterNone];
[self.locationMeneger setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
[self.locationMeneger startUpdatingLocation];
}
}
[super viewDidLoad];
}我的日志打印了我们的"all ok“,所以位置菜单是无效的,但是没有委托。
// for iOS 6 and more
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
NSLog(@"je updatan");
[NSThread detachNewThreadSelector:@selector(NearByPinOnMap) toTarget:self withObject:nil];
}
// for iOS 5 and lass
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(NSArray *)locations fromLocation:(CLLocation *)oldLocation{
NSLog(@"nov update");
[NSThread detachNewThreadSelector:@selector(NearByPinOnMap) toTarget:self withObject:nil];
}
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
NSLog(@"error maps : %@", error.description);
}几乎从来没有打过电话。有几次这个didUpdateToLocation被调用了,但是下一次没有改变就没有了。
有人能帮帮我吗。
发布于 2013-09-18 12:11:32
尝试设置desiredAccuracy参数。你可以在这里读到:苹果文档。您还可以检查您的类是否采用CLLocationManagerDelegate协议。
https://stackoverflow.com/questions/18871807
复制相似问题