0
votes

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?

1
Tried setting imageView.userInteractionEnabled = YES;?user529758
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
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.user529758
And read the docs. The same thing is written in UIView's class reference.user529758
Thanks for the response, but I'm not sure exactly what you're suggesting. I got the structure of my subclass from here: mobiledevelopertips.com/user-interface/… 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

1 Answers

5
votes

IOS 5: UIScrollView not pass touches to nextResponder

Instead of:

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

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