位置管理器更新频率,iphone [英] Location Manager update frequency, iphone

查看:140
本文介绍了位置管理器更新频率,iphone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为myLocation的CLLocation管理器。

I have a CLLocation manager called "myLocation".

myLocation = [[CLLocationManager alloc] init];
    myLocation.desiredAccuracy = kCLLocationAccuracyBestForNavigation ;
    myLocation.distanceFilter = 10 ;
    myLocation.delegate=self;



    locationEnabledBool = [CLLocationManager locationServicesEnabled];



    if (locationEnabledBool ==NO || ( [CLLocationManager  authorizationStatus] == kCLAuthorizationStatusDenied)) {

    //  LocationText.text = @"Location Service Disabled ";
        UIAlertView *locationAlert = [[UIAlertView alloc] initWithTitle:@"Location Service Disabled" 
                                                        message:@"To re-enable, please go to Settings and turn on Location Service for this app." 
                                                       delegate:nil 
                                              cancelButtonTitle:@"OK" 
                                              otherButtonTitles:nil];
        [locationAlert show];
        [locationAlert release];

    }

        [myLocation startUpdatingLocation];

和位置更新功能

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{

NSLog(@"old location is %f, %f ", oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
NSLog(@"new location is %f,%f",newLocation.coordinate.latitude, newLocation.coordinate.longitude );
}

有没有办法找到位置管理器更新的频率,如果可以的话增加还是减少?

Is there a way to find frequency of location manager update, and If it can be increased or decreased?

推荐答案

您的位置更新只当调用该方法开始 [的LocationManager startUpdatingLocation]

Your location update starts only when you call the method [locationManager startUpdatingLocation].

您可以使用 NSTimer 来控制更新的频率。每当需要位置更新时,定期调用 startUpdatingLocation 方法,然后立即调用 stopUpdatingLocation 方法。下次您只能按照 NSTimer 中设置的时间间隔更新位置。

You can control the frequency of the update using an NSTimer. Call the startUpdatingLocation method at regular intervals whenever you need a location update and then immediately call the stopUpdatingLocation method. The next time you will get a location update only at the interval you have set in the NSTimer.

这篇关于位置管理器更新频率,iphone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆