我注意到在我的应用程序中,当我调用 startUpdatingLocation 时,我的 UI 会短暂锁定,而我认为设备会收集位置数据。这是典型的吗?有什么方法可以限制吗?这是我的代码的样子
-(void)getUserLocation {
if (!locationManager)
{
locationManager = [[CLLocationManager alloc]init];
}
[locationManager setDelegate:self];
[locationManager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
self.userCoordinate = newLocation.coordinate;
NSLog(@"user coordinate in location manager: %f,%f",self.userCoordinate.latitude,self.userCoordinate.longitude);
[locationManager stopUpdatingLocation];
locationManager = nil;
userLocationAvailable = YES;
[self getDataForScrollView];
}
有任何想法吗?谢谢!