我在iOS 4.0和4.2中都无法获取当前位置的经纬度,实际上我想在我的应用程序中从当前位置到特定位置绘制路线,我在我的应用程序中尝试了许多方法,但是无法得到结果。
如果有人知道,请回复我。
谢谢! :)
我在iOS 4.0和4.2中都无法获取当前位置的经纬度,实际上我想在我的应用程序中从当前位置到特定位置绘制路线,我在我的应用程序中尝试了许多方法,但是无法得到结果。
如果有人知道,请回复我。
谢谢! :)
CLLocationManager *lm = [[CLLocationManager alloc] init];
lm.delegate = self;
lm.desiredAccuracy = kCLLocationAccuracyBest;
lm.distanceFilter = kCLDistanceFilterNone;
[lm startUpdatingLocation];
CLLocation *location = [lm location];
CLLocationCoordinate2D coord;
coord.longitude = location.coordinate.longitude;
coord.latitude = location.coordinate.latitude;
// or a one shot fill
coord = [location coordinate];
location
很可能是 nil
或过时的。建议采用 locationManager:didUpdateToLocation:fromLocation:
方法实现来接收位置更新。 - Mark Adamscoord.longitude = location.coordinate.longitude; coord.latitude = location.coordinate.latitude;
- cloudsurfin您需要调用CLLocationManager(请参见Apple文档)。- startUpdatingLocation
和- stopUpdatingLocation
是您将要使用的主要方法之一。
CLLocationManager
吗? - EmptyStack