Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to called TouchesMoved for 2 different UIImageView
    text
    copied!<p>Hello I have 2 <code>UIImageViews</code> in <code>UIView</code>.</p> <p>Once I touch on <code>UIImageView</code> <code>touchesBegan</code> method gets called. But once I drag on <code>UIImageView</code> then <code>touchesMoved</code> is called. But at the same time <code>touchesMoved</code> for the second <code>UIImageView</code> is also called.</p> <p>Can you please help me how i can get <code>touchesMoved</code> event for both the <code>UIImageViews</code>? </p> <p>This is my code</p> <pre><code>-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self.view]; if (CGRectContainsPoint(iv1.frame,currentPoint)==YES) NSLog(@"iv1 Begin"); if (CGRectContainsPoint(iv2.frame,currentPoint)==YES) NSLog(@"iv2 Begin"); } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self.view]; if(CGRectContainsPoint(iv1.frame,currentPoint)==YES) NSLog(@"iv1 Moved NO"); if(CGRectContainsPoint(iv2.frame,currentPoint)==NO) NSLog(@"iv1 Moved YES"); if(CGRectContainsPoint(iv2.frame,currentPoint)==YES) NSLog(@"iv2 Moved NO"); if(CGRectContainsPoint(iv2.frame,currentPoint)==NO) NSLog(@"iv2 Moved NO"); } -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self.view]; if (CGRectContainsPoint(iv1.frame,currentPoint)==YES) NSLog(@"iv1 End"); if (CGRectContainsPoint(iv1.frame,currentPoint)==YES) NSLog(@"iv2 End"); } </code></pre>
 

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