I am trying to find a way to do a zoom in and out via a button. If I put code within the method didAddAnnotationViews
, it will set the initial zoom perfectly. I tried to get the zoom to change with the code below, but it keeps on crashing saying:
Unrecognized Selector sent to Instance
How can I run this in an 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];
};
My issue was that I was trying to pass in the MapView in the IBAction line which I couldnt do. It did not know what to do with it. I referenced my MapView in the code instead of trying to pass it in the method...
You can put this is any IBAction method now and it will zoom in to the map.