0

I am trying to drop movable UIImageViews within a subclassed UIScrollView so that I can drag them around my UIScrollView. I subclassed UISCrollView and the dropping behavior is working, but when I try to drag the images, touchesMoved is only evaluated once. The touchesMoved method in my subclass of UIScrollView looks like this:

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    if (!self.dragging) {
        [self.nextResponder touchesMoved: touches withEvent:event]; 
    }else{
        [super touchesEnded:touches withEvent:event];
    }        
}

It is being called continuously during a moving touch, as it should. Can anyone think of a reason that the touchesMoved method in my view controller would only be called once?

  • Tried setting `imageView.userInteractionEnabled = YES;`? –  Jul 30 '12 at 17:57
  • Yes, I've set userInteractionEnabled. I should mention that upon a touchesMoved event, the imageView does move slightly in the direction that I start moving. – user1467778 Jul 30 '12 at 17:59
  • 1
    Ah btw you're calling `[self.nextResponder touchesMoved:withEvent:]` which is explicitly prohibited by Apple's docs. Instead of sending to self.nextResponder, send to super. –  Jul 30 '12 at 18:01
  • 1
    **And read the docs.** The same thing is written in UIView's class reference. –  Jul 30 '12 at 18:02
  • Thanks for the response, but I'm not sure exactly what you're suggesting. I got the structure of my subclass from here: http://mobiledevelopertips.com/user-interface/detect-single-tap-in-uiscrollview.html but I saw a lot of similar things in other StackOverflow posts. When I change it to [super touchesMoved: touches withEvent:event]; the method isn't called at all. – user1467778 Jul 30 '12 at 18:52

1 Answers1

5

IOS 5: UIScrollView not pass touches to nextResponder

Instead of:

[self.nextResponder touchesMoved:touches withEvent:event]; Use:

[[self.nextResponder nextResponder] touchesMoved:touches withEvent:event];

Community
  • 1
  • 1
jold
  • 152
  • 1
  • 4