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 6351971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:06:49+00:00 2026-05-24T22:06:49+00:00

I implemented gesture recognizer in UIMapView just as described in the accepted answer to

  • 0

I implemented gesture recognizer in UIMapView just as described in the accepted answer to this question: How to intercept touches events on a MKMapView or UIWebView objects?

Single touches are recognized correctly. However, when I changed the superclass of my class from UIGestureRecognizer to UIPinchGestureRecognizer in order to recognize map scaling, everything stopped working.
Now TouchesEnded event occurs only when the user double tap the annotation on map (don’t know, why!) and doesn’t occur when the user pinches the map (zoom in or out doesn’t matter).

PS I’m using iOS SDK 4.3 and testing my app in simulator if that matters.

The code of mapViewController.m – viewDidLoad method:

 - (void)viewDidLoad
 {
     [super viewDidLoad];
     MapGestureRecognizer *changeMapPositionRecognizer = [[MapGestureRecognizer alloc] init];
     changeMapPositionRecognizer.touchesEndedCallback = ^(NSSet * touches, UIEvent * event) 
     {
        ...
     };
     [self.mapView addGestureRecognizer:changeMapPositionRecognizer];
     [changeMapPositionRecognizer release];
}

The code of MapGestureRecognizer.h:

#import <UIKit/UIKit.h>
typedef void (^TouchesEventBlock) (NSSet * touches, UIEvent * event);
@interface MapGestureRecognizer : UIPinchGestureRecognizer    
@property(nonatomic, copy) TouchesEventBlock touchesEndedCallback;
@end

The code of MapGestureRecognizer.m:

#import "MapGestureRecognizer.h"

@implementation MapGestureRecognizer
@synthesize touchesEndedCallback = _touchesEndedCallback;

- (id)init
{
    self = [super init];
    if (self) {
        self.cancelsTouchesInView = NO;
}

    return self;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (self.touchesEndedCallback)
    {
        self.touchesEndedCallback(touches, event);
        NSLog(@"Touches ended, callback done");
    }
    else
    {
        NSLog(@"Touches ended, callback skipped");
    }
}

- (void) dealloc
{
    [super dealloc];
}

@end

What should I correct in to make pinch gesture to be recognized?

  • 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-24T22:06:51+00:00Added an answer on May 24, 2026 at 10:06 pm

    I’m not sure why you need to subclass UIPinchGestureRecognizer instead of using it directly as-is.

    Also not sure why you need the gesture recognizer to detect map scaling which you could do by using the delegate methods regionWillChangeAnimated and regionDidChangeAnimated and comparing the span before and after. Unless you are trying to detect the scaling as it is happening (and not wanting to wait until user finishes the gesture)

    The gesture recognizer may not be getting called because the map view’s own pinch gesture recognizer is getting called instead.

    To have your recognizer called as well as the map view’s, implement the UIGestureRecognizer delegate method shouldRecognizeSimultaneouslyWithGestureRecognizer and return YES:

    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer 
        shouldRecognizeSimultaneouslyWithGestureRecognizer:
            (UIGestureRecognizer *)otherGestureRecognizer
    {
        return YES;
    }
    

    Make sure the gesture recognizer’s delegate property is set or that method won’t get called either.

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

Sidebar

Related Questions

I've implemented that default swipe-to-delete gesture in UITableView, and now I feel that this
In cellForRowAtIndexPath: method I have implemented gesture recognizer for long press, -(UITableViewCell *)tableView:(UITableView *)tableView
Implemented a generic repository with several Methods. One of those is this: public IEnumerable<T>
I have set up a gesture recognizer for my table cell in my IOS5
I am using a custom gesture recognizer (as given in the link Intercepting/Hijacking iPhone
I am trying to implement gesture recognizer type application with UIButtons . The UIButtons
I want to implement all possible Gesture recognizers on image,like rotate gesture recognizer zoom
I am trying to implement an Ipad application with gesture recognizer. In my application
I am new to iphone and xcode. This may be a very simple question
Hi I implemented this function and i can hand the gestures but how can

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.