2012-09-21 79 views
0

我能夠獲得用戶當前位置的經度和高度,但不是位置的名稱。我用如下用戶位置屬性:如何在NSLog中獲取MapView的當前位置?

NSLog(@"Current location=%@",mapView.userLocation); 

,但是,它給了我作爲 Current location=<MKUserLocation: 0x1f59e8c0>

輸出我想要得到那個位置,而不是0x1f59e8c0的字符串值。這個怎麼做?

回答

1

在的MKMapView文檔開始:http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html

您可以按照鏈條向下尋找經度是CLLocationCoordinate2D的一部分(而且是雙) http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CoreLocationDataTypesRef/Reference/reference.html#//apple_ref/doc/c_ref/CLLocationCoordinate2D

NSLog(@"Current longitude = %f",mapView.userLocation.location.coordinate.longitude); 
1
NSLog(@"Current location %@",mapView.userLocation.title); 

P.S.還有更多的財產字幕

+0

但,這給了我價值,當前位置=當前位置 – stack