zoukankan      html  css  js  c++  java
  • 设置UIScrollView只可以水平或者竖直滚动

    UIScrollView里边包含多个UIWebView:

    可以通过设置contentSize的值,设置其width为UIScrollerView可视区域的宽度:即UIScrollView的width,在设置一些alwaysBounceHorizontal之类的属性,那么就只能竖直方向滚动;

    我需要设置UIScrollView只能横向滚动,UIWebView响应竖直滚动:

    UIScrollView *contentView = [[[UIScrollView alloc] initWithFrame:frame] autorelease];
    contentView.scrollEnabled = YES;
    contentView.pagingEnabled = YES;
    contentView.showsHorizontalScrollIndicator = NO;
    contentView.showsVerticalScrollIndicator = NO;
    contentView.alwaysBounceVertical = NO;
    contentView.alwaysBounceHorizontal = NO;
    [contentView setBackgroundColor:[UIColor redColor]];
    [contentView setBounces:NO];
    

      再在加载UIWebView的地方设置每个WebView的frame和UIScrollView的contentSize;

    [self.tabBarView.contentView setContentSize:CGSizeMake(self.tabBarView.frame.size.width * i, self.tabBarView.frame.size.height - kTabBarHeight)];
    

      这里我是在BCTabBarController基础上修改的,所以

    self.tabBarView.frame.size.width相当于屏幕宽度,i为UIScrollView包含的UIWebView数量,
    self.tabBarView.frame.size.height - kTabBarHeight为UIScrollView的固定高度并且等于UIWebView的高度,这样就能让UIScrollView不响应竖直方向滚动,让UIWebView响应竖直滚动。

    bingo!
  • 相关阅读:
    spring reference
    Connector for Python
    LDAP
    REST
    java利用泛型实现不同类型可变参数
    java细节知识
    事务隔离的级别
    servlet cdi注入
    session and cookie简析
    CORS’s source, principle and implementation
  • 原文地址:https://www.cnblogs.com/greywolf/p/3286743.html
Copyright © 2011-2022 走看看