zoukankan      html  css  js  c++  java
  • TableView遇到的问题

    1.所建立的TableView滑动不到底部的问题:

    tableView继承scrollerView,当tableview开始建立的时候,会先计算每个cell的高度和每个headerview的高度、footerView的高度的总和就是contentSize的总和。当建立tableview的时候,frame的设置有时候会影响tableview的滑动,原因由于view的上面还有navigationbar的高度44和状态栏的高度20,若是tableview需要占整个屏幕的大小需要将控制器view的高度减去他们两的高度

    2.当tableView有多个section的时候,section的视图随着tableview滑动到顶部时即卡在顶部不随其滑动

    解决方法监控scrollerView的滑动

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView

    {

    CGFloat sectionHeaderHeight = 40;

    if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {

    scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);

    }

    else if (scrollView.contentOffset.y>=sectionHeaderHeight) {

    scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);

    }

    }

    但是此方法会造成tableview的滑动不顺畅

    建议重写headview中的setframe的方法

    - (void)setFrame:(CGRect)frame{

    CGRectsectionRect = [self.tableViewrectForSection:self.section];

    CGRectnewFrame =CGRectMake(CGRectGetMinX(frame),CGRectGetMinY(sectionRect),CGRectGetWidth(frame),CGRectGetHeight(frame)); [supersetFrame:newFrame];

    }

    此处的方法也会造成不顺畅

    最好的办法是更改tableview的类型为group

  • 相关阅读:
    [Bzoj2120]数颜色
    [Bzoj2049][Sdoi2008]Cave 洞穴勘测
    [2019上海网络赛F题]Rhyme scheme
    [2019上海网络赛J题]Stone game
    Codeforces Round #688 (Div. 2) C
    Educational Codeforces Round 99 (Rated for Div. 2) D
    Educational Codeforces Round 99 (Rated for Div. 2) B
    Codeforces Round #685 (Div. 2) D
    Codeforces Round #685 (Div. 2) C
    Codeforces Round #685 (Div. 2) B
  • 原文地址:https://www.cnblogs.com/qiumuan/p/5135967.html
Copyright © 2011-2022 走看看