My UIWebView should not allow vertical scrolling. However, horizontal scrolling should possible.
I have been looking through the documentation, but couldn't find any hints.
The following code disables both scrolling directions, but I want to only disable vertical:
myWebView.scrollView.scrollEnabled = NO;
How do I solve this problem?
To make it full work, write:
I have just added the last two lines, because when you write it like pnizzle did, you can't scroll from the right to the left side, but still from the left to the right.
Good luck
Leave scrollEnabled == YES. The scroll view will restrict scrolling based on the content size. To allow only horizontal scrolling, set the contentSize something like this:
The width should be related to the width of whatever is being scrolled inside the scroll view.
Enable Horizontal scrolling and disable Vertical scrolling:
the 2nd line there will hide the vertical scroll indicator. Checking if "scrollView.contentOffset.y < zero" will disable the bouncing when you attempt to scroll downwards. You can also do: scrollView.bounces=NO to do the same thing!! By just looking at Rama Rao's answer i can tell that his code will reset the scrollView to (0.0) the moment you try to scroll vertically, thereby moving you away from your horizontal position, which is not good.
Enable vertical scrolling and disable Horizontal scrolling:
PEACE
By this way we can solve the issue. Take a global scrollview object as below:
set delegate to scroll view then
-(void) scrollViewDidScroll:(UIScrollView *)scrollView
will be called and you can get the result. I checked it in both versions(iOS 5 & iOS 4.2)