3

I am developing a iOS app.

I add an UIPinchGestureRecognizer to listen the pinch out action.

[[self view]addGestureRecognizer:[[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchOutGesture:)]];

-(void)handlePinchOutGesture:(UIPinchGestureRecognizer*)recognizer {
    if (recognizer.state == UIGestureRecognizerStateBegan) {
        // Do something

    } else if (recognizer.state == UIGestureRecognizerStateChanged) {
        // Do something

    } else {
       // Do something

    }
}

However, I want to add an UITapGestureRecognizer as well so that it will have the same effect when user tap an item.

Is there a way to simulate "pinch out" gesture programmatically?

Dragon warrior
  • 1,644
  • 2
  • 24
  • 37

1 Answers1

3

It's difficult to synthesize a touch (or multi touch) event on the iOS: you have to use non public APIs, so you have a high probability of getting rejected during Apple review.

Here's a link that demonstrates how to synthesize a touch event on the iPhone

http://www.cocoawithlove.com/2008/10/synthesizing-touch-event-on-iphone.html

Woodstock
  • 22,184
  • 15
  • 80
  • 118