MAPKIT userLocation 좌표를 반환합니다
문제
현재 위치에 대한 LAT/긴 좌표를 반환하려고 할 때마다 오류에 대한 설명없이 응용 프로그램이 충돌합니다 ...
NSLog(@"%@", mapView.userLocation.location.coordinate);
전화가 위치를 찾을 때까지 기다리고 있습니다 ...
해결책
mapView.userLocation.location.coordinate
구조체입니다 %@
형식 지정자는 객체를 기대합니다. 이것은 작동합니다 :
NSLog(@"%f, %f", mapView.userLocation.location.coordinate.latitude,
mapView.userLocation.location.coordinate.longitude);
다른 팁
어떤 이유로, 이것은 나에게 효과가 없었습니다. 그것은 나를 좌표로 데려 가고 있습니다 (0.0000, 0.0000). 아래는 체크 아웃 할 기회가있는 경우 내 코드입니다. 도와 주셔서 감사합니다!
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
mapView.showsUserLocation=TRUE;
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
CLLocationCoordinate2D myCoord = {mapView.userLocation.location.coordinate.latitude,mapView.userLocation.location.coordinate.longitude};
[mapView setCenterCoordinate:myCoord animated:YES];
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapView setRegion:region animated:YES];
[mapView setDelegate:self];
제휴하지 않습니다 StackOverflow