码迷,mamicode.com
首页 > Web开发 > 详细

UIWebview 禁止某个方向滚动

时间:2014-07-18 17:27:37      阅读:286      评论:0      收藏:0      [点我收藏+]

标签:os   io   re   c   line   ar   

Enable Horizontal scrolling and disable Vertical scrolling:

myWebView.scrollView.delegate = self;
[myWebView.scrollView setShowsVerticalScrollIndicator:NO];

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

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:

myWebView.scrollView.delegate = self;
[myWebview.scrollView setShowsHorizontalScrollIndicator:NO];

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

 

UIWebview 禁止某个方向滚动,布布扣,bubuko.com

UIWebview 禁止某个方向滚动

标签:os   io   re   c   line   ar   

原文地址:http://www.cnblogs.com/XCoderLiu/p/3853240.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!