我注意到,在我的應用程序中,當我打電話給startUpdatingLocation時,我的UI簡要鎖定,而我認爲設備收集位置數據。這是典型的,有什麼辦法來限制嗎?繼承人我的代碼看起來像CLLocationManager startUpdatingLocation造成滯後
-(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];
}
什麼想法?謝謝!
我試圖把它放在後臺隊列中無濟於事。 –