I'm打了一下,与iPhone SDK和我想表明我的应用程序的当前速度。 有这么多的应用程序,可以做到这一点真的很精确,尤其是在低速像跑步或骑自行车。 我见过的最好的是RunKeeper。
但是,在我的应用程序,速度是绝对不正确的。 在低速时它总是空的,只有在更高的速度下它显示了一些值,但他们很少更新,而不是真正有用。
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
if (newLocation.timestamp > oldLocation.timestamp &&
newLocation.verticalAccuracy > 0.0f && // GPS is active
newLocation.horizontalAccuracy < 500.0f && // GPS is active
//newLocation.horizontalAccuracy < kCLLocationAccuracyHundredMeters && // good quality GPS signal
//newLocation.speed > 1.0f && // enough movment for accurate speed and course measurement
oldLocation != nil) // oldLocation is nil on the first reading
{
double speed = (newLocation.speed * 3.6);
[self updateDisplayWithSpeed:speed];
//double direction = newLocation.course;
}
}
有没有人有那个工作代码? 或者你可以告诉我what's错我的吗?