6
我目前有這個設置,我很想在計算距離時將Km從公里改爲Miles。這裏是我當前的代碼:CLLocationDistance從公里更改爲里程
CLLocation *userloc = [[CLLocation alloc] initWithLatitude:locationManager.location.coordinate.latitude longitude:locationManager.location.coordinate.longitude];
CLLocation *loc = [[CLLocation alloc] initWithLatitude:lat longitude:lon];
CLLocationDistance distance2 = [userloc distanceFromLocation:loc]/ 1000;
NSLog(@"%f",distance2);
[distance setText:[NSString stringWithFormat:@"%.2f km", distance2]];
}
非常感謝您的幫助! – user3288168
不客氣。作爲新手,請不要忘記接受答案,通過點擊答案旁邊的複選標記來解決您的問題。 – rmaddy
Ups!感謝那!不知道接受答案......你可以看到我是一個新手。 ;) – user3288168