- (void)findCurrentLocation { self.isFirstUpdate = YES; [self.locationManager startUpdatingLocation]; } - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { if (self.isFirstUpdate) { self.isFirstUpdate = NO; return; } CLLocation *location = [locations lastObject]; /*当定位成功后,如果horizontalAccuracy大于0,说明定位有效 horizontalAccuracy,该位置的纬度和经度确定的圆的中心,并且这个值表示圆的半径。负值表示该位置的纬度和经度是无效的。 */ if (location.horizontalAccuracy > 0) { self.currentLocation = location; [self.locationManager stopUpdatingLocation]; } }
版权声明:本文为博主原创文章,未经博主允许不得转载。