我查看了现有的问题并相信我遵守规则,但有些原因我的地图没有缩放。我已经设置了一个断点来确保我的坐标正在通过,一切似乎都没问题。
以下是我的代码。
- (void)viewDidLoad
{
[super viewDidLoad];
[self configureView];
mapView = [[MKMapView alloc]initWithFrame:CGRectMake(20, 20, 260, 169)];
mapView.delegate = self;
mapView.mapType = MKMapTypeStandard;
[self.view addSubview:mapView];
}
- (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated {
Bar *maps = self.detailItem;
MKCoordinateSpan span;
span.latitudeDelta = .02;
span.longitudeDelta = .02;
CLLocationDegrees latDegree = [maps.barLat doubleValue];
CLLocationDegrees longDegree = [maps.barLong doubleValue];
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(latDegree, longDegree);
MKCoordinateRegion region;
region.center = location;
region.span = span;
[mapView setRegion:region animated:TRUE];
}
答案 0 :(得分:0)
我并不完全清楚你在mapView:regionWillChangeAnimated:
回调中尝试做什么......当区域要改变时会被调用(例如,在用户平移或缩放时),而你正在通过指挥另一个地区的变化做出回应。也许那只是为了调试?
我认为您的问题是为什么您的地图不会缩放,对吧?
如果您想确保地图支持缩放,请添加以下代码:
mapView = [[MKMapView alloc]initWithFrame:CGRectMake(20, 20, 260, 169)];
mapView.delegate = self;
mapView.mapType = MKMapTypeStandard;
mapView.zoomEnabled = YES;
mapView.multipleTouchEnabled = YES;
但是,我想知道你所看到的只是你的地图非常小。它不到屏幕尺寸的一半。在模拟器上,我发现很难执行捏合手势(导致变焦),甚至在我的真实设备上,将我的两根手指放入那个小视图区域也不容易。但是,在这两个平台上,我确实看到了允许缩放的代码(iOS 5.0)。
你可以增加地图的frame
大小,并确保它不仅仅是在一个小区域内难以捏造吗?