我試圖獲取用戶當前的經緯度與此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