0

我正在尝试找到一种通过按钮进行放大和缩小的方法。如果我将代码放入方法didAddAnnotationViews中,它将完美地设置初始缩放。我试图用下面的代码来改变缩放,但它一直在崩溃说:

无法识别的选择器发送到实例

如何在 IBAction 中运行它?

-(IBAction)ZoomIn:(MKCoordinateSpan)coordinateSpanWithMapView:(MKMapView *)mv centerCoordinate:(CLLocationCoordinate2D)location
{
   MKCoordinateRegion region;
   MKCoordinateSpan span; 
   span.latitudeDelta=0.05;
   span.longitudeDelta=0.05;
   location = mv.userLocation.coordinate;
   location = mv.userLocation.location.coordinate;
   region.span=span;
   region.center=location;
   [mv setRegion:region animated:TRUE];
   [mv regionThatFits:region]; 
};
4

2 回答 2

0

我的问题是我试图在 IBAction 行中传递 MapView,这是我做不到的。它不知道如何处理它。我在代码中引用了我的 MapView,而不是尝试在方法中传递它......

CLLocationCoordinate2D location;
MKCoordinateRegion region;
MKCoordinateSpan span; 
span.latitudeDelta=1.00;
span.longitudeDelta=1.00;
location = self.myMap.userLocation.coordinate;
location = self.myMap.userLocation.location.coordinate;
region.span=span;
region.center=location;
[self.LightUpMap setRegion:region animated:TRUE];
[self.LightUpMap regionThatFits:region];

您现在可以将其设置为任何 IBAction 方法,它会放大地图。

于 2012-01-17T04:33:28.230 回答
0
-(void)zoomOut:btnMinus
{
  MKCoordinateSpan span = mapView.region.span;
  span.latitudeDelta = span.latitudeDelta * 2;
  span.longitudeDelta = span.longitudeDelta * 2;
  region.span=span;
  [mapView setRegion:region animated:YES];
  for(int j=2;j<count;j++)
  { places[j]=1;}
  [self filterAnnotations];  
}
于 2014-01-31T07:58:17.450 回答