zoukankan      html  css  js  c++  java
  • Swift

     总结,实现了 cell预设高度, header 预设高度, footer预设高, 不会报错

    1. UITableview先走 预设高度的代理

    预设cell高度

    func tableView( tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat{

      return 30

    }

    预设头部高度 :

    func tableview(_ tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -> CGFloat{

      return 40

    }

    预设尾部高度:

    func tableview(_ tableView: UITableView, estimatedHeightForFooterInSection section: Int) -> CGFloat {

      return 33

    }

    然后再走 初始化方法 :

        override init(reuseIdentifier: String?) {

            super.init(reuseIdentifier: reuseIdentifier)

            configUI()

        }

    所以 设置UITableview 自定义头部 和尾部 一定要先实现  预设高度的代理, 预估一个高度, 不然约束报错 

    真正的cell高度, 区尾高度 和区头高度 直接让UITableview 自己去获取就行

    func tableView(tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat{

         return UITableView.automaticDimension

    }

        /// 分区头部view的高度

        func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat{

            return UITableView.automaticDimension

        }

        /// 分区尾部view的高度

        func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat{

            return UITableView.automaticDimension

        }

  • 相关阅读:
    HDU 3879 Base Station 最大权闭合图
    自己定义头像处理,轻巧有用,非常多强大的小技巧在里面哦,快来赞美我一下吧^_^
    【Spring实战】—— 8 自动装配
    【Spring实战】—— 7 复杂集合类型的注入
    【Spring实战】—— 6 内部Bean
    【Spring实战】—— 5 设值注入
    【Spring实战】—— 4 Spring中bean的init和destroy方法讲解
    【Spring实战】—— 3 使用facotry-method创建单例Bean总结
    【Spring实战】—— 2 构造注入
    【Spring实战】—— 1 入门讲解
  • 原文地址:https://www.cnblogs.com/qingzZ/p/11933979.html
Copyright © 2011-2022 走看看