zoukankan      html  css  js  c++  java
  • ios设置点击状态栏返回到顶部

    在一个scrollview中横向有多个tableview,点击状态栏,tableview要返回到顶部
    要将所有scrollview 以及tableview 的scrollToTop设置为NO。显示的tableview的scrollToTop设置为TRUE。

    @property(nonatomic,strong) NSMutableArray *tdoclist;

    //设置一个数组,存储tableview

    self.tdoclist=[NSMutableArray arrayWithCapacity:10];
    for (int i=0; i<[self.category count]+1; i++) {
    [[[CommenData alloc]init] setCategoryIndex:[self getCategoryIndex:i]];
    if (i==0) {
    self.doctable=[self.storyboard instantiateViewControllerWithIdentifier:@"docview"];
    self.doctable.view.frame=CGRectMake(r.size.width*i, 0.0, r.size.width, r.size.height-40);
    [self addChildViewController:self.doctable];
    self.doctable.tableView.scrollsToTop=YES;
    [self.tdoclist addObject:self.doctable];
    [self.tableScroll addSubview:self.doctable.view];
    }else{
    self.tdoctable=[self.storyboard instantiateViewControllerWithIdentifier:@"tdocview"];
    self.tdoctable.view.frame=CGRectMake(r.size.width*i, 0.0, r.size.width, r.size.height-40);
    [self addChildViewController:self.tdoctable];
    self.tdoctable.tableView.scrollsToTop=NO;
    [self.tdoclist addObject:self.tdoctable];
    [self.tableScroll addSubview:self.tdoctable.view];
    }
    }

    //左右滑动页面切换tableview时切换 tableview的scrollToTop属性

    -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
        //加载之后的一页
        if (scrollView==self.tableScroll) {
                    CGFloat pageWidth=scrollView.frame.size.width;
            int page=floor((scrollView.contentOffset.x-pageWidth/2)/pageWidth)+1;
            if (page!=indexPage) {
                //可以继续滚动
                if (indexPage<[self.category count]+1) {
                    indexPage=page;
                    [self.scrollnavi setSelectedIndex:indexPage];
                    for (int i=0; i<self.tdoclist.count; i++) {
                        TDocTableViewController *tdocs = self.tdoclist[i] ;
                        if (i==indexPage) {
                            tdocs.tableView.scrollsToTop=YES;
                        }else{
                            tdocs.tableView.scrollsToTop=NO;
                        }
                    }
                    //若直接用self.tdoc 只会刷新最后一个页面
                     TDocTableViewController *tdoc = self.tdoclist[indexPage] ;
                    [tdoc refreshData];
                    
                }
                
            }

        }

    }
  • 相关阅读:
    server-conf-PPTConf
    client-autoReport-ppt
    client-autoReport-common
    浏览器书签导出
    微信公众号JSAPI支付-多公众号向同一商户号支付的问题解决
    Kettle 4.4.0 通过 Java 代码 输出日志到表
    spring tx:advice事务配置
    Spring异常捕获而且回滚事务的方法
    移动端服务器i-jetty下载编译安装及问题解决系列
    I-Jetty部署war包到安卓手机
  • 原文地址:https://www.cnblogs.com/qiulilin/p/4541223.html
Copyright © 2011-2022 走看看