我正试图找到一种通过按钮进行放大和缩小的方法。如果我把代码放在方法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];
};
我的问题是,我试图在MapView的IBAction行中传递,但我做不到。它不知道该怎么办。我在代码中引用了我的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方法,它会放大到地图上。
-(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];
}