我试图获取用户当前的经纬度与此viewDidLoad方法。由此产生的地图正确指出了当前的位置,但NSLog一贯显示:iPhone当前用户位置坐标显示为(0,0)
2009-09-19 16:45:29.765 Mapper[671:207] user latitude = 0.000000
2009-09-19 16:45:29.772 Mapper[671:207] user longitude = 0.000000
任何人都知道我在这里失踪?在此先感谢您的帮助!
- (void)viewDidLoad {
[super viewDidLoad];
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
[mapView setShowsUserLocation:YES];
CLLocation *userLoc = mapView.userLocation.location;
CLLocationCoordinate2D userCoordinate = userLoc.coordinate;
NSLog(@"user latitude = %f",userCoordinate.latitude);
NSLog(@"user longitude = %f",userCoordinate.longitude);
}
,那么什么是获取当前位置的坐标的方式之后执行seletor? – ennuikiller 2009-09-19 22:12:32
如果您只想查找当前位置,则完全不需要使用Maps API。您可以直接查询核心位置。 http://developer.apple.com/mac/library/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html – AlBlue 2009-09-20 09:34:44