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