1

I have four UIImageViews placed on a circular UIView. Dragging the UIView rotates the view. But when I drag the UIImageView, the rotation does not occur. The UIImageView is eating the touches.

I subclassed the UIImageView and tried this:

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [self.superview touchesMoved:touches withEvent:event];
    [super touchesMoved:touches withEvent:event];
}

That doesn't seem to solve the problem. I tried disabling touches on the UIImageView - [imageView setUserInteraction:NO]. That doesn't solve the problem either. I know there are similar questions been asked. But none seem to solve my problem.

Thanks.

Anil
  • 2,430
  • 3
  • 37
  • 55

1 Answers1

4

Try setting userInteractionEnabled to NO on your UIImageViews, it should prevent them from consuming the touches.

Levi
  • 7,313
  • 2
  • 32
  • 44
  • Sorry, I didn't know what you meant by "disabling touches". In case you disable them, is your `touchesMoved:withEvent:` method still called? If yes, then I'd suggest using a `UIPanGestureRecognizer` to detect the draging. – Levi Feb 18 '15 at 11:19
  • Yes. touchesMoved is still called. So I put a pan gesture on the super view? Is there any other way? – Anil Feb 18 '15 at 11:20
  • I just tried out the solution with `userInteractionEnabled` set to `NO` and for me it works, meaning that only the superview's `touchesMoved:withEvent:` is called (even when I drag on the subview), so something else must be wrong with your setup – Levi Feb 18 '15 at 11:33
  • I'm not sure what's going wrong. Everything seems fine. – Anil Feb 18 '15 at 12:03
  • @Anil Maybe you have another subview somewhere there? Did you try to implement `hitTest:withEvent:(UIEvent *)event`? What happens if you put a breakpoint in `hitTest`, does it enter the breakpoint? – Nat Feb 18 '15 at 12:05