Current Location Bug in Xcode 4.5

前端 未结 3 1953
鱼传尺愫
鱼传尺愫 2021-01-07 00:35

In Xcode 4.5 apple introduced apple new maps. My application heavliy requires map services. And I have noticed in my application it shows the wrong current location until yo

3条回答
  •  我在风中等你
    2021-01-07 01:25

    you should check the timestamp .. if i understand your app logic correctly, you could do something like -

    - (void)locationManager:(CLLocationManager *)manager
        didUpdateToLocation:(CLLocation *)newLocation
               fromLocation:(CLLocation *)oldLocation {
    
    NSDate* time = newLocation.timestamp;
        NSTimeInterval timePeriod = [time timeIntervalSinceNow];
        if(timePeriod < SOME_MINIMUM_TIME_PERIOD ) { //for eg: timePeriod < 1.0
                   totalDistance += [newLocation distanceFromLocation:oldLocation];
        } else {
            // skip.. or do what you do on a 'location-not-updated' event
        }
    }
    

提交回复
热议问题