आप को लागू करने से इस समस्या का समाधान कर सकते हैं एक कस्टम PanGestureRecognizer
जो मूल स्पर्श बिंदु बचाता है और इसे कॉलर के लिए उपलब्ध कराता है।
मैं इस मार्ग पर गया क्योंकि मैं पैन जेस्चर ट्रिगर करने के लिए स्थानांतरित दूरी को नियंत्रित करना चाहता था।
यह आपकी स्थिति के लिए अधिक हो सकता है, लेकिन पूरी तरह से काम करता है और यह लगता है उससे कम मुश्किल है।
संपर्क सूत्र निर्देशांक पाने के लिए आपको सिर्फ फोन:
[sender touchPointInView:yourView]
बजाय
:
#import "PanGestureRecognizer.h"
#import <UIKit/UIGestureRecognizerSubclass.h>
@implementation PanGestureRecognizer
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
UITouch *touch = [touches anyObject];
// touchPoint is defined as: @property (assign,nonatomic) CGPoint touchPoint;
self.touchPoint = [touch locationInView:nil];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesMoved:touches withEvent:event];
UITouch *touch = [touches anyObject];
CGPoint p = [touch locationInView:nil];
// customize the pan distance threshold
CGFloat dx = fabs(p.x-self.touchPoint.x);
CGFloat dy = fabs(p.y-self.touchPoint.y);
if (dx > 2 || dy > 2) {
if (self.state == UIGestureRecognizerStatePossible) {
[self setState:UIGestureRecognizerStateBegan];
}
else {
[self setState:UIGestureRecognizerStateChanged];
}
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesEnded:touches withEvent:event];
if (self.state == UIGestureRecognizerStateChanged) {
[self setState:UIGestureRecognizerStateEnded];
}
else {
[self setState:UIGestureRecognizerStateCancelled];
}
}
- (void) reset
{
}
// this returns the original touch point
- (CGPoint) touchPointInView:(UIView *)view
{
CGPoint p = [view convertPoint:self.touchPoint fromView:nil];
return p;
}
@end
इस कड़ी में मदद मिल सकती - http://www.icodeblog.com/2010/10/14/working-with-uigesturerecognizers/ – Coffee