1

現在地の緯度/経度座標を返そうとすると、エラーの説明もなくアプリケーションがクラッシュします...

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

電話も場所を見つけるまで待っています...

4

2 に答える 2

5

mapView.userLocation.location.coordinateは構造体ですが、%@フォーマット指定子はオブジェクトを想定しています。これはうまくいきます:

NSLog(@"%f, %f", mapView.userLocation.location.coordinate.latitude,
                 mapView.userLocation.location.coordinate.longitude);
于 2009-10-30T21:02:13.543 に答える
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];
于 2010-12-20T22:57:28.177 に答える