I've a UIScrollView that contains an UIImageView. The UIScrollView lets zooming and panning through the UIImageView.
The problem is that I would like know the finger movement every time, and I'm trying to catch the event with touchesMoved method. But it's not working, despite touchesBegan and touchesEnded that are called correctly.
In fact, touchesMoved is called if the finger movement is really small, and the UIScrollView doesn't started panning. At the moment that UIScrollView starts getting moved, the event stops being called.
Somebody know what's the problem and how to fix it? I've thought that maybe the UIImageView inside is catching the event or something like that.
Try to use the UIScrollViewDelegate to trace the offset change or zoom scale changes.
Or check the
zoomScale
value change ofUIScrollView
betweentouchesBegan: & (touchesMoved: or touchesCancelled:) events
.Create a subclass of UIScrollView class and override the touchesBegan: and other touch methods as follows:
Please check this to recognize touch events(began,moved,ended) using pan gesture of the scrollview,
Actually, that's really quite a problem, as the UIScrollView does "eat" TouchesMoved events (even if propagates several first ones).
So, I've just come up with the approach to get the events directly from UIWindow. That's for sure not the best approach in the application structure sense, but in some custom situation (which was exactly what I needed) is fine.
(Examples are in MonoTouch C#).
Create your custom UIWindow (I don't show here how to replace standard UIWindow with MyWindow due to my custom logic (using MvvmCross framework), but that's pretty easy and usually done in appDelegate initialization logic - you will find that in google/stack overflow):
and in the place to handle the events subscribe for the custom events handlers:
handlers like (that's all by your own):
In that case the events will be handling simultaneously (in both places: yours and UIScrollView), so additionally if you want, you can cancel the window's event propagation only if you want to prevent any other handlers to apply except yours (you can add "Handled" flag to your handlers, for instance).
The scrollview property
canCancelContentTouches = NO
allows the touch events to be passed up the responder chain.