문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top