zoukankan      html  css  js  c++  java
  • iOS开发中的错误整理,百思项目'我的'模块,tableFooterViewHeight的问题.提醒自己对KVO和Block的运用欠缺

    一.错误分析:由于tableFooterView中的数据是通过请求服务器后得到的,tableFooterViewHeight也是根据请求过来的数据经过布局子控件而计算出来的.(注意:计算高度是在子线程中执行的),导致了给TableView设置了tableFooterView,tableFooterView的高度为0.如下图:

    二.解决方案一:通过KVO监听自定义tableFooterView的高度变化

    解决方案二:通过block,当自定义tableFooterView计算出高度后,才将自定义控件赋值给TableView

    • 自定义控件中定义一个block成员变量

    • 计算出高度后执行block

    • 给TableView添加自定义控件时,给block赋值,block中设置自己的tableFooterView

    最终效果:

  • 相关阅读:
    Generate Parentheses
    Length of Last Word
    Maximum Subarray
    Count and Say
    二分搜索算法
    Search Insert Position
    Implement strStr()
    Remove Element
    Remove Duplicates from Sorted Array
    Remove Nth Node From End of List
  • 原文地址:https://www.cnblogs.com/gchlcc/p/5545096.html
Copyright © 2011-2022 走看看