Prevent scrolling in a MKMapView, also when zooming

You can try to handle the pinch gestures yourself using a UIPinchGestureRecognizer: First set scrollEnabled and zoomEnabled to NO and create the gesture recognizer: UIPinchGestureRecognizer* recognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)]; [self.mapView addGestureRecognizer:recognizer]; In the recognizer handler adjust the MKCoordinateSpan according to the zoom scale: – (void)handlePinch:(UIPinchGestureRecognizer*)recognizer { static MKCoordinateRegion originalRegion; if (recognizer.state == UIGestureRecognizerStateBegan) … Read more

Why am I crashing after MKMapView is freed if I’m no longer using it?

This is because of the way MKMapView works. There’s an operation pending, so MapKit is retaining the MKMapView and it hasn’t actually been deallocated yet. That isn’t itself a problem. The problem is that it’s still sending messages to your delegate. The workaround is simple: As part of your view controller’s cleanup set the map … Read more

is there a way to get directions in mkmapview using a built in apple API?

In iOS 7, you can get and display directions using MKDirectionsRequest. Here’s some sample code for displaying directions from the current location to another map item: MKDirectionsRequest *request = [[MKDirectionsRequest alloc] init]; [request setSource:[MKMapItem mapItemForCurrentLocation]]; [request setDestination:myMapItem]; [request setTransportType:MKDirectionsTransportTypeAny]; // This can be limited to automobile and walking directions. [request setRequestsAlternateRoutes:YES]; // Gives you several … Read more

Button action in mkannotation view not working?

You need to set frame for this button. which is not really seen in the code. Adjust frame as you want by x position and y position. UIButton *tembtn=[UIButton buttonWithType:UIButtonTypeCustom]; // Frame required to render on position and size. Add below line [tembtn setFrame:CGRectMake(0, 0, 100, 50)]; [tembtn setTitle:@”More info” forState:UIControlStateNormal]; [tembtn addTarget:self action:@selector(annotationBtnAction:) forControlEvents:UIControlEventTouchUpInside]; … Read more

UIModalTransitionStylePartialCurl with UITabBarController

I’ve scoured StackOverflow (and the Internet) for a solution to this problem. The question has been asked many times, but as you note, never sufficiently answered. Many solutions give an acceptable solution if it is unimportant whether, e.g., a lower toolbar curls up as well. Others have provided a solution using UIView animations / CoreAnimation … Read more

Convert MKCoordinateRegion to MKMapRect

To add another implementation to the pile: – (MKMapRect)MKMapRectForCoordinateRegion:(MKCoordinateRegion)region { MKMapPoint a = MKMapPointForCoordinate(CLLocationCoordinate2DMake( region.center.latitude + region.span.latitudeDelta / 2, region.center.longitude – region.span.longitudeDelta / 2)); MKMapPoint b = MKMapPointForCoordinate(CLLocationCoordinate2DMake( region.center.latitude – region.span.latitudeDelta / 2, region.center.longitude + region.span.longitudeDelta / 2)); return MKMapRectMake(MIN(a.x,b.x), MIN(a.y,b.y), ABS(a.x-b.x), ABS(a.y-b.y)); } NB: There are many ways to convert between MKMapRect and MKCoordinateRegion. … Read more

Custom MKPinAnnotation callout bubble similar to default callout bubble

I have developed a custom callout bubble that is nearly identical to the system callout bubble, but gives more flexibility over the height and content. It should be fairly trivial to adjust the appearance to suit your needs. See my post on the Asynchrony Solutions blog for example code and the steps required to implement … Read more

How to add a push pin to a MKMapView(IOS) when touching?

You can use a UILongPressGestureRecognizer for this. Wherever you create or initialize the mapview, first attach the recognizer to it: UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; lpgr.minimumPressDuration = 2.0; //user needs to press for 2 seconds [self.mapView addGestureRecognizer:lpgr]; [lpgr release]; Then in the gesture handler: – (void)handleLongPress:(UIGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state != UIGestureRecognizerStateBegan) return; … Read more