Tono Nam
Tono Nam

Reputation: 36080

UIPinchGestureRecognizer require two touches

I have added the following gesture recognizers to a view:

UIPinchGestureRecognizer *pch= [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(ViewPinching:)];
[[self view] addGestureRecognizer:pch];

// and

UIPanGestureRecognizer *d = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(ViewDragging:)];
[d setMinimumNumberOfTouches:4];
[[self view] addGestureRecognizer:d];

I want to fire the event when 4 fingers are dragged and when I do that the Pinch gesture recognizer fires instead of the Pan gesture recognizer. I was thinking that maybe I could fix this problem if I restrict the UIPinchGestureRecognizer to be fired only if touches.count=2

edit

I don't know if this will be practical or not. Maybe I could add:

 UIPinchGestureRecognizer *pch= [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(ViewPinching:)];
[[self view] addGestureRecognizer:pch];

every time touches start if there is two touches I will add that event and remove it ontouchesended.

Upvotes: 1

Views: 1828

Answers (1)

CodaFi
CodaFi

Reputation: 43330

This is ultimately a bad idea. A 4-finger pinch in iOS 5 will close your app, and a 4 finger pan will switch to the next app (obviously not good for UX). If you absolutely must use 4 fingers, make a subclass of UIGestureRecognizer and do the pinching logic yourself. Let me apologize ahead of time for not having an example, as your use case is quite unique.

Upvotes: 2

Related Questions