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

  • 相关阅读:
    九.Protobuf3特殊类型
    八.Protobuf3更新消息类型(添加新的字段)
    七.Protobuf3 嵌套类型
    六.Protobuf3引入其他.proto文件
    五.Protobuf3 枚举
    四.Protobuf3 缺省值
    VC 在调用main函数之前的操作
    Windows下的代码注入
    C 堆内存管理
    VC++ 崩溃处理以及打印调用堆栈
  • 原文地址:https://www.cnblogs.com/FZP5/p/5253069.html
Copyright © 2011-2022 走看看