/ / देखने पर इशारे को सीमित करना [डुप्लिकेट] - आईओएस, यूजेस्टेक्चररोगिग्नर

देखने पर इशारा सीमित [डुप्लिकेट] - आईओएस, uigesturerecognizer

यह है कि मैं कैसे देखने पर इशारा जोड़ते हैं

- (void)_addPanGestureToView:(UIView *)view {
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(_handlePan:)];
panGesture.delegate = self;
panGesture.maximumNumberOfTouches = 1;
panGesture.minimumNumberOfTouches = 1;
[view addGestureRecognizer:panGesture];
}

सब कुछ पूरी तरह से काम कर रहा है, लेकिन इशारा पूरे विचार पर है कि मैं इशारे की तरह कुछ कैसे कर सकता हूं केवल आधे दृश्य में जवाब दें?

उत्तर:

उत्तर № 1 के लिए 7

क्यों न सिर्फ उपयोग करें CGRectContainsPoint() और जांच लें कि आपके दृश्य के भीतर स्थित स्थान उस क्षेत्र के भीतर है जिसे आप चाहते हैं। यदि यह t "नहीं है, तो इसे अनदेखा करें:

- (void)panGestureDetected:(UIPanGestureRecognizer *)sender
{
CGPoint location = [sender locationInView:sender.view];
CGRect someRect = ...

if (CGRectContainsPoint(someRect, location)) {
// point is in specified area
}
}

जवाब के लिए 3 № 2

सबसे आसान समाधान उस क्षेत्र पर एक पारदर्शी दृष्टिकोण जोड़ना होगा जहां आप चाहते हैं कि आप काम करने के लिए हावभाव पहचानकर्ता हैं, और उस दृश्य में इशारा जोड़ें (और उस दृश्य को पाठ्यक्रम के एक उप के रूप में)। जैसे:

- (void)_addPanGestureToView:(UIView *)view {
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(_handlePan:)];
panGesture.delegate = self;
panGesture.maximumNumberOfTouches = 1;
panGesture.minimumNumberOfTouches = 1;

UIView *viewForGesture = [[UIView alloc] initWithFrame:CGRectMake(....)]; //your frame
[viewForGesture addGestureRecognizer:panGesture];
[view addSubview:viewForGesture];
}