我需要一些帮助。
当我打开地图时,我必须 grep 我当前的位置并将其发送到服务器以从中获取所有其他引脚。(就像附近的东西)。
我设置 :
- (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];
}
我的日志打印我们的“一切正常”,因此位置meneger 已初始化,但没有委托
// 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 被调用,但下次没有更改。
谁能帮助我。