zoukankan      html  css  js  c++  java
  • UIWebview 禁止某个方向滚动

    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);
    }

     

  • 相关阅读:
    [BZOJ3105][CQOI2013]新Nim游戏
    [BZOJ4592][SHOI2015]脑洞治疗仪
    [BZOJ3551][ONTAK2010]Peaks加强版
    [BZOJ2229][ZJOI2011]最小割
    [BZOJ4519][CQOI2016]不同的最小割
    [BZOJ3532][SDOI2014]LIS
    [BZOJ2668][CQOI2012]交换棋子
    [BZOJ3504][CQOI2014]危桥
    Java抽象类
    Java方法覆盖重写
  • 原文地址:https://www.cnblogs.com/XCoderLiu/p/3853240.html
Copyright © 2011-2022 走看看