大家好,又见面了,我是你们的朋友全栈君。
- (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]; }}
版权声明:本文为博主原创文章,未经博主允许不得转载。
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/154464.html原文链接:https://javaforall.net