How to capture Tap gesture on MKMapView

You can use a UIGestureRecognizer to detect touches on the map view. Instead of a single tap, however, I would suggest looking for a double tap (UITapGestureRecognizer) or a long press (UILongPressGestureRecognizer). A single tap might interfere with the user trying to single tap on the pin or callout itself. In the place where you … Read more

Stop iOS 7 MKMapView from leaking memory

I had faced the same issue and (thanks to Stackoverflow) fixed it by changing MKMapType in viewWillDisappear and deallocating/setting its delegate to nil.As it still sends message to delegates. This is documented in MKMapViewDelegate Protocol Reference: Before releasing an MKMapView object for which you have set a delegate, remember to set that object’s delegate property … Read more

MapKit not showing custom Annotation pin image on iOS9

Instead of creating an MKPinAnnotationView, create a plain MKAnnotationView. The MKPinAnnotationView subclass tends to ignore the image property since it’s designed to show the standard red, green, purple pins only (via the pinColor property). When you switch to MKAnnotationView, you’ll have to comment out the animatesDrop line as well since that property is specific to … Read more

Is there way to limit MKMapView maximum zoom level?

You could use the mapView:regionWillChangeAnimated: delegate method to listen for region change events, and if the region is wider than your maximum region, set it back to the max region with setRegion:animated: to indicate to your user that they can’t zoom out that far. Here’s the methods: – (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated – (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated

How to disable user interaction on MKMapView?

The key is to disable zooms and scrolls. In Objective-C: self.mapView.zoomEnabled = false; self.mapView.scrollEnabled = false; self.mapView.userInteractionEnabled = false; Or Swift: mapView.isZoomEnabled = false mapView.isScrollEnabled = false mapView.isUserInteractionEnabled = false By the way, if you want a static map, you might consider using MKMapSnapshotter instead. This creates an image representation of a map. If you … Read more

tech