0
votes

So i have a UIWebView that is meant to only scroll horizontally, and its in a UIScrollView that is only meant to scroll vertically. I have almost managed to achieve this, but i have a slight problem.

The UIWebiew's scroll content height is set to the height of the webviews frame, so that it wont scroll vertically, but even when this is the case, it still seems to consume the vertical scrolling event (sometimes), since i can see the side scroll bar show, but it wont scroll (and doesnt scroll the scrollview that the webview is contained in).

It needs to be like this because there are some elements that need to scroll vertically with the webview, but not horizontally (think of the safari app how the addressbar scrolls with the webview)

does anyone know how i would pass the vertical scroll event through but keep the horizontal scroll event for the UIWebView?

i had a look at this answer but its not quite what im looking for

update:

so typically just after i ask the question i find a suitable answer on another question... (had been searching for a few hours now) this answer should do the trick for me, ill give it a go and report back

2

2 Answers

0
votes

Just set

scrollView.alwaysBounceVertical = NO;
scrollView.contentSize = CGSizeMake(
    scrollView.frame.size.width, scrollView.contentSize.height);
scrollView.showsVerticalScrollIndicator = NO;

Edit: doesn't seems to work. Too bad..

Try implementing

- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gst 
    shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)gst2 {
    return YES;
}

..in your view containing the scrollView and webView, or even the scrollView itself (containing the webView).

0
votes

So the solution i found that i posted in the question works for the most part, it does exactly what i need, but for some reason after a webpage loads, it scrolls the headerbar away showing just the webpage, which isnt the end of the world but its not pretty. it seems the event fires after the webViewDidFinishLoad: so i cant just reposition it back to the top. Ill keep tinkering around, maybe i can find out why its doing it.