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之间的距离;

  • 相关阅读:
    requirejs 初探
    jquery版本
    querystring
    git 使用记录
    nodejs mocha 单元测试
    Jquery之promise
    nodejs express命令问题
    Sublime Text 资料整理
    SQL SERVER 2008 R2 自动备份并删除过期备份数据
    无法编辑的word解密
  • 原文地址:https://www.cnblogs.com/FZP5/p/5253069.html
Copyright © 2011-2022 走看看