Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Formally I had accepted termes's answer first and that worked too, but I have found a more simpler solution to this process. There is no need for two gesture recognizers, it is achievable with a simple tap gesture recognizer with number of touches count to two. Here is the code:</p> <pre><code>UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; tapRecognizer.numberOfTapsRequired = 1; tapRecognizer.numberOfTouchesRequired = 2; tapRecognizer.delegate = self; [self addGestureRecognizer:tapRecognizer]; </code></pre> <p>Now, in the handle tap method we can easily get the two touch points by "<a href="http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/Reference/Reference.html#//apple_ref/occ/instm/UIGestureRecognizer/locationOfTouch%3ainView%3a" rel="nofollow">locationOfTouch:inView:</a>", a instance method of UIGestureRecognizer class. So in the <code>handleTap:</code> method we need to check if the two touch points are in the desired location. Here is the code:</p> <pre><code>-(void)handleTap:(UITapGestureRecognizer*)recognizer { if (recognizer.state == UIGestureRecognizerStateEnded) { CGPoint point1 = [recognizer locationOfTouch:0 self]; CGPoint point2 = [recognizer locationOfTouch:1 self]; if ([self validateTapIn:point1 and:point2]) { resultLabel.text = @"success"; } } } -(BOOL)validateTapIn:(CGPoint)point1 and:(CGPoint)point2 { return (CGRectContainsPoint(label1.frame, point1) &amp;&amp; CGRectContainsPoint(label2.frame,:point2)) || (CGRectContainsPoint(label1.frame, point2) &amp;&amp; CGRectContainsPoint(label2.frame, point1)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload