Trouble with CLLocation method distanceFromLocation: Inaccurate results

后端 未结 4 1230
天命终不由人
天命终不由人 2020-12-15 11:16

I am trying to use the distanceFromLocation: method to calculate the total distance that I am walking with my iPhone in my hand. So far, I have been searching all over to h

4条回答
  •  误落风尘
    2020-12-15 11:22

    You are not setting the accuracy of your location manager. Go through apple docs, it is something like accuracy = bestfornavigation. or something. That should drain battery like hell but is meant for this kind of purposes.

    edit: just remembered i had it at hand.

    // Create the Location Manager
    locationManager = [[CLLocationManager alloc] init];
    
    // Configure the Location Manager
    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
    

提交回复
热议问题