Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5927993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:14:31+00:00 2026-05-22T14:14:31+00:00

If you pinch to zoom in/out in Apple’s Maps application while tracking the device’s

  • 0

If you pinch to zoom in/out in Apple’s Maps application while tracking the device’s location, the “pan” component of the pinch gesture is ignored and the blue location indicator remains fixed in the centre of the screen. This is not the case when using a plain MKMapView.

Assuming I already have the user’s location, how could I achieve this effect? I’ve tried resetting the centre coordinate in the delegate’s regionDid/WillChangeAnimated: methods but they’re only called at the start and end of the gesture. I also tried adding a UIPinchGestureRecognizer subclass that resets the centre coordinate when the touches move, but this resulted in rendering glitches.


Edit: For those who are interested, the following works for me.

// CenterGestureRecognizer.h
@interface CenterGestureRecognizer : UIPinchGestureRecognizer

- (id)initWithMapView:(MKMapView *)mapView;

@end

// CenterGestureRecognizer.m
@interface CenterGestureRecognizer ()

- (void)handlePinchGesture;

@property (nonatomic, assign) MKMapView *mapView;

@end

@implementation CenterGestureRecognizer

- (id)initWithMapView:(MKMapView *)mapView {
  if (mapView == nil) {
    [NSException raise:NSInvalidArgumentException format:@"mapView cannot be nil."];
  }

  if ((self = [super initWithTarget:self action:@selector(handlePinchGesture)])) {
    self.mapView = mapView;
  }

  return self;
}

- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer {
  return NO;
}

- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer {
  return NO;
}

- (void)handlePinchGesture {
  CLLocation *location = self.mapView.userLocation.location;
  if (location != nil) {
    [self.mapView setCenterCoordinate:location.coordinate];
  }
}

@synthesize mapView;

@end

Then simply add it to your MKMapView:

[self.mapView addGestureRecognizer:[[[CenterGestureRecognizer alloc] initWithMapView:self.mapView] autorelease]];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:14:32+00:00Added an answer on May 22, 2026 at 2:14 pm

    When the user pinches the screen on the actual device (as opposed to the simulator), it causes both a pan and a pinch gesture – the pinch contains the “zoom” element of the motion, and the pan contains the vertical and horizontal change. You need to be intercepting and blocking the pan, and that means using a UIPanGestureRecognizer.

    Set scrollEnabled to NO, then add a UIPanGestureRecognizer to reset the center coordinate. The combination will block both single-finger panning and the pan component of a pinch.


    Edit to add more details, and after seeing your code: touchesMoved:withEvent is called after the pan has already begun, so if you change the MKMapView’s center there, you’ll get the herky-jerky rendering problems you’ve described. What you really need is to create a UIPanGestureRecognizer with a target-action, like so:

        UIPanGestureRecognizer *pan = [[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didRecognizePan)] autorelease];
        pan.delegate = self;
        [self.mapView addGestureRecognizer:pan];
    

    …and then add a didRecognizePan method to your controller, and do your center-resetting there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out how to disable the default pinch to zoom
I have been trying to implement pinch zoom/in-out for PhotoView (a UIImageView instance) using
For my application, i have used pinch zoom feature by adapting from the tutorial
if any have idea to pinch zoom,zoom in ,zoom out ,rotation(left & right),drag &
I have had pinch-to-zoom working pretty well for a few application versions now using
I'm trying to implement pinch-to-zoom gestures exactly as in Google Maps. I watched a
Is there an accepted way of performing (pinch) zoom on a view that is
I need to be able to turn pinch-zoom on and off using the viewport
I wrote a custom pinch gesture recognizer for my ScrollView's zooming, and I handle
I'm using pan, pinch, and rotate UIGestureRecognizers to allow the user to put certain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.