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 回答