views:

206

answers:

1

Hi,

I have a UIWebView which is embedded in a UIScrollView. The webView is resized so that the scroll view manages all the scrolling (I need control over the scrolling).

In the webView I have disabled userSelection via '-webkit-user-select: none;'

Everything is working fine except one annoying detail. When I hold down my finger on the content before starting to scroll for about a second the scrollView won't scroll. My best guess is, that it has something to do with userSelection. The time is about the same it usually takes for the copy/paste/magnifying-thing to appear which usually disables scrolling as well.

I am running out of ideas on how to solve this. Every help would be greatly appreciated!

Thanks!

EDIT: Another aspect of the problem is, that the non-scrolling actually triggers JS-Eventhandler (click, mousedown, mouseup) inside my webView which leads to surprising app behavior. The user puts her finger down, waits, scrolls, nothing happens, removes her finger and this is perceived as a click, which feels wrong from a users perspective.

A: 

I would guess what is happening is that after that short duration, the scrollview is no longer interpreting the touch as being on it's view and instead passes the touch down to it's content views.

Have you tried delaying the content touches for the scrollview? This will essentially tell the scrollview to delay taking action on the touch event and instead to briefly monitor the touch and if the touch moves then it recognizes it as a swipe gesture for scrolling. If it doesn't move, it will eventually pass the touch along to it's subviews.

scrollView.delaysContentTouches = YES;

I think even then, there is a standard delay time before the scrollview will pass the touch events along the responder chain. If you hold for too long, it's going to naturally perceive it as being a press down event rather than a scroll event.

iWasRobbed
delaysContentTouches was already set to YES. I toggled it with no effect.
Mo
If your comment above about the webview capturing the click is correct, it means the scrollview is passing along the touch event since you are not moving your finger within the timed duration. That's what it is supposed to do otherwise how would it be able to handle actual clicks within the webview? If the standard time is not long enough for you, you'd have to handle the touch events yourself which is a big can of worms.
iWasRobbed
If you don't want the webview to handle touches, you should set it's `userInteractionEnabled` to NO.
iWasRobbed