How can I tell if the user wants to just scroll and not use the UIImageView inside the UIScrollView?

I have implemented a UIScrollView that contains a grid of UIImageView objects. For both types - supervisor and its subview - userInteractionEnabled - YES. When the user scrolls and his / her finger touches the UIImageView, he immediately recognizes clicking on it, which is not what I want;)

Inside UIImageView objects, I have this method:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    if ([touch view] == self && [touch tapCount] >= 1) {
        NSLog(@"Cooooool! The user touched me!");
    }
}

      

Is there a way to find out something like "oh no, the user really only wanted to scroll, so don't take it too seriously!"? Basically, I want a home screen behavior where the finger can touch the icon, but when the user starts scrolling and removes the finger, the trojan app won't launch.

0


a source to share


1 answer


UIScrollView

already performed this behavior for you. If the user dragged quickly enough, your method touchesBegan:withEvent:

simply won't get called.

If, on the other hand, the user is slow and the scroll view forwards the touch to your subclass UIImageView

, but then only implements the user intended for the scroll, it will call your own class method -(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event

.



Just implement it and you will be notified of canceled touches.

+2


a source







All Articles