Ios locationManager:未调用DidUpdateLocation
我需要一些帮助 当我打开地图时,我必须grep我的当前位置,并将其发送到服务器以从中获取所有其他PIN。(比如附近的东西) 我设定:Ios locationManager:未调用DidUpdateLocation,ios,maps,mkmapview,cllocationmanager,Ios,Maps,Mkmapview,Cllocationmanager,我需要一些帮助 当我打开地图时,我必须grep我的当前位置,并将其发送到服务器以从中获取所有其他PIN。(比如附近的东西) 我设定: - (void)viewDidLoad { // if location services are on if([CLLocationManager locationServicesEnabled]) { // if location services are restricted do nothing i
- (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];
}
我的日志会打印我们的“一切正常”,所以位置菜单是初始化的,但没有任何代理
// 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,但是下次没有更改的时候没有
有人能帮我吗。尝试设置所需的精度参数。您可以在此处阅读:。
您还可以检查您的类是否采用了CLLocationManagerDelegate协议嗨,我尝试了一下,我发现如果我等待足够长的时间,它会更频繁地调用委托。有没有其他方法可以更快地获取当前位置?