Tuesday, August 26, 2014

Disable horizontal scrolling in a UIWebview

Firstly I tried

   

but failed.

Then I found the solution that works for me:

  1. set the webV to hide its indicator and set the scroll delegate
        webV.scrollView.delegate = self;    [webV.scrollView setShowsHorizontalScrollIndicator:NO];
  2. add the delegate method:

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView.contentOffset.x > 0) {
        scrollView.contentOffset = CGPointMake(0, scrollView.contentOffset.y);
    }
}

No comments: