Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView重新加载节不会触发ViewForFooterInstruction?_Ios_Swift_Uitableview_Tablefooterview - Fatal编程技术网

Ios UITableView重新加载节不会触发ViewForFooterInstruction?

Ios UITableView重新加载节不会触发ViewForFooterInstruction?,ios,swift,uitableview,tablefooterview,Ios,Swift,Uitableview,Tablefooterview,我正在尝试构建一个类似于iOS本机提醒应用程序的应用程序。其中有一个带有页眉和页脚的项目列表。每个单元格都包含一个UITextView,当用户键入时,它将动态更改单元格高度。页脚视图包含相同的单元格视图,只是我希望它是一个页脚,这样它就可以粘贴到底部视图。我已将单元格设置为动态高度 checklistTable.rowHeight = UITableViewAutomaticDimension checklistTable.estimatedRowHeight = 60 checklistTa

我正在尝试构建一个类似于iOS本机提醒应用程序的应用程序。其中有一个带有页眉和页脚的项目列表。每个单元格都包含一个
UITextView
,当用户键入时,它将动态更改单元格高度。页脚视图包含相同的单元格视图,只是我希望它是一个页脚,这样它就可以粘贴到底部视图。我已将单元格设置为动态高度

checklistTable.rowHeight = UITableViewAutomaticDimension
checklistTable.estimatedRowHeight = 60

checklistTable.sectionFooterHeight = UITableViewAutomaticDimension
checklistTable.estimatedSectionFooterHeight = 60
这是在键入时更新单元格高度的逻辑,这非常适用于常规单元格,但不适用于页脚视图。我在中设置了一个断点 viewForFooterInSection,初始加载后从未调用它

func textViewDidChange(_ textView: UITextView) {

    let startHeight = textView.frame.size.height
    let calcHeight = textView.sizeThatFits(textView.frame.size).height

    if startHeight != calcHeight {
        UIView.setAnimationsEnabled(false)
        tableView?.beginUpdates()

        if cellType == .footer {
            tableView?.reloadSections(IndexSet(integer: 0), with: .automatic)
        }

        tableView?.endUpdates()
        UIView.setAnimationsEnabled(true)
    }
}

谁能给我指一下正确的方向吗?谢谢

UIView
&调用
tableView?上启用和禁用动画。beginUpdate()
同时看起来模棱两可。
简单地说,调用
reloadSections
应该可以工作,比如:

if startHeight != calcHeight {

        if cellType == .footer {
            tableView?.reloadSections(IndexSet(integer: 0), with: .automatic)
        }
    }

ViewForFooterInstitution最初是否被调用过?API文档只说此方法更新单元格,而不是页眉和页脚。@nirav是的,ViewForFooterInstitution得到调用初始化。在滚动过程中,您是否实现了tableView:HeightForFooterInstruction方法?这是一个先决条件。嗨@Nirav,只需添加HeightforFooterInstitution并返回UITableViewAutomaticDimension,仍然不走运:(谢谢@ystack。我试过了,没什么区别:(哇!你试过执行一个简单的
表。重载数据()
?重新加载数据可能会重新绘制页脚。但我确实在寻找一种优雅的方法来更新节页脚,而不必重新加载整个表,重新加载也会导致键盘关闭,这在用户键入时是我不希望看到的。