zoukankan      html  css  js  c++  java
  • cell与cell之间的间距问题,以及section跟随屏幕滑动而滑动问题

    苹果在cell与cell之间默认没有间距,这样有时候不能满足我们界面要求,所以我们就需要将cell设置为分组模式(也就是每组一行或者多行,分为n组),然后我们就可以在代理中根据自己的需求设计cell之间的距离,但实际是添加了section,看起来像是间距

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

    {

        return 8;

    }

     设置完section之后我们需要根据自己的需求设置section是否需要根据我们的界面上滑,而不是卡在上面,这时候我们需要在代理中设置

    其中 CGFloat sectionHeaderHeight = 是你上面设置section的数值,我的是8;

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView {

        if (scrollView ==self.tableView)

        {

            CGFloat sectionHeaderHeight = 8;

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

            }

        }

    }

    然后运行就完美解决了cell与cell之间的距离;

  • 相关阅读:
    java三层架构:持久层、业务层、表现层
    Spring:Spring JDBCTemplate & 声明式事务
    Spring:AOP
    Spring:IOC控制反转
    Mybatis: 加载策略及注解开发
    Mybatis 配置文件深入
    Mybatis:基本应用
    前后端项目接口联调
    springboot整合jsp
    IDEA出现URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)
  • 原文地址:https://www.cnblogs.com/FZP5/p/5253069.html
Copyright © 2011-2022 走看看