Ios 位置管理器startupdating位置问题

Ios 位置管理器startupdating位置问题,ios,iphone,objective-c,location,core-location,Ios,Iphone,Objective C,Location,Core Location,我正在使用CoreLocation更新我的设备位置 -(void)viewDidLoad { [super viewDidLoad]; self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.desiredAccuracy = kCLLocationAccuracyBest; self.locationManager.delegate = self; [self.locationManager s

我正在使用CoreLocation更新我的设备位置

-(void)viewDidLoad
{
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.delegate = self;
[self.locationManager startUpdatingLocation];
 }


-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {

   CLLocation *loc = locations.lastObject;
   double speed = loc.speed;
   NSLog(@"speed-----%f ", speed);
    }
当我用模拟器测试它时,它每秒钟更新一次,我得到了速度(通过给模拟器定位高速公路驱动) 但当我用真正的设备进行测试时,它会在10-15秒内更新位置。 为什么会这样,请帮帮我

您应该尝试将“PausesLocationUpdateAutomatically”属性设置为NO。因此,
self.locationManager.PausesLocationUpdateAutomatically=NO


默认值为“是”,在这种情况下,LocationManager在“它认为”位置不太可能更改时停止更新位置。

您应该尝试将“pausesLocationUpdatesAutomatically”属性设置为否。因此,self.LocationManager.pausesLocationUpdatesAutomatically=NO;默认值为“是”,在这种情况下,LocationManager会在“它认为”位置不太可能更改时停止更新位置。谢谢,它成功了。请把它作为回答。