【发布时间】:2013-01-17 06:21:12
【问题描述】:
我正在尝试获取用户位置并将其显示在 mapView 中,并在 iOS6 中使用以下代码:
- (void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
if (locations.count>0) {
for (CLLocation *location in locations) {
[locationList addObject:location];
if (location != nil) {
// Zoom to the current user location.
MKCoordinateRegion userLocation =[mapView regionThatFits: MKCoordinateRegionMakeWithDistance(location.coordinate, 150.0, 150.0)];
[mapView setRegion:userLocation animated:YES];
NSLog(@"%f,%f", mapView.centerCoordinate.latitude,mapView.centerCoordinate.longitude);
NSLog(@"%f,%f", mapView.region.span.latitudeDelta,mapView.region.span.longitudeDelta);
}
}
}
}
但位置更新后,[mapView setRegion:userLocation animated:YES] 不会对mapView 的区域进行任何更改,但用户位置可以显示为蓝点。 NSLog 打印如下:
nan,nan
0.000000,360.000000
这意味着没有任何改变。我检查了大多数与地图相关的问题,他们只是调用此方法并在地图中心获取位置显示。
我想知道为什么我可以把用户位置放到地图中心。
【问题讨论】:
标签: objective-c ios6 mkmapview