2009-10-30 2 views
1

Mapkit 사용자 위치 좌표 반환

내 현재 위치에 대한 위도/경도 좌표를 반환 할 때마다 내 응용 프로그램이 오류에 대한 설명없이 충돌합니다 ...

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

전화가 위치를 찾을 때까지 기다리고 있습니다 ...

답변

5

mapView.userLocation.location.coordinate은 구조체이며 형식 지정자는 %@ 형식 지정자가 있어야합니다. 작동 여부 :

NSLog(@"%f, %f", mapView.userLocation.location.coordinate.latitude, 
       mapView.userLocation.location.coordinate.longitude); 
0

무엇인가의 이유로이 기능이 작동하지 않습니다. 좌표 (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]; 
관련 문제