views:

1447

answers:

1

Hi,

I'd like to capture user's swipe event for my iPhone application.

as per apple, It can be easily get it from touchesMoved:withEvent:.

I have UIView which contains navigationbar on the top, toolbar at bottom, in between it has uiwebView.

Now when user swipes i want to capture this event, but i am not able to get user's touch event for UIwebView.

I have my touchesMoved event in my viewcontroller, Where do i write this touch?

Please help me..

+1  A: 

You could subclass UIWebView, only overwriting the touchesMoved, touchesStarted, touchesEnded, and touchesCancelled methods. Do your swipe detection in those methods, and have them call [super ...] if the call does not belong to a swipe.

The problem here might be that detecting the swipe does not prevent the default behavior of the UIWebView. The super class also needs to know when touches start, move, end, or cancel. This way it's able to perform the right selector on the delegate.

So when you overwrite those methods and do not call [super ...], or only if it's not a swipe, the behavior of UIWebView itself is probably undefined. That's why I mentioned you should always call [super ...] in your own implementation.

Edit: SO did not like me putting strings between less-then and greater-then brackets. So in the above, wherever I mentioned [super ...], please fill in touchesStarted, touchesMoved, touchesEnded, and touchesCancelled on the dots ....

drvdijk
thanks for the help. can you provide me some tutorials or links or code base?
finally i managed to get swipe when user touches on uiwebview.but due to this i am not able to zoom or scroll uiwebview.please help me.
Remember to call [super touchesMoved], [super touchesStarted], [super touchesEnded], [super touchesCancelled] from within your own implementation of those methods!
drvdijk