首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >locationManager:未调用

locationManager:未调用
EN

Stack Overflow用户
提问于 2013-09-18 12:05:08
回答 1查看 1.7K关注 0票数 0

我需要些帮助。

当我打开地图时,我必须重新定位我的当前位置,并将其发送到服务器以获取所有其他引脚。(就像附近的东西)。

我设定:

代码语言:javascript
复制
 - (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“,所以位置菜单是无效的,但是没有委托。

代码语言:javascript
复制
// 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被调用了,但是下一次没有改变就没有了。

有人能帮帮我吗。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-18 12:11:32

尝试设置desiredAccuracy参数。你可以在这里读到:苹果文档。您还可以检查您的类是否采用CLLocationManagerDelegate协议。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18871807

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档