Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top