使用 reloadData 的最后一节未调用 viewForFooterInSection
viewForFooterInSection not called for last section with reloadData
我想使用 reloadData 刷新部分页脚,但现在除了最后一个部分之外的所有部分都已更新 - 即使页脚可见,也不会调用 viewForFooterInSection。滚动视图是为最后一节调用 viewForFooterInSection 的唯一方法。这种行为的原因可能是什么?我正在使用自动布局。
编辑:实施 heightForFooterInSection 以支持不同的页脚高度,但也许应该只是 return AutomaticDimension 并且逻辑应该放在其他地方?
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
switch(tableView) {
case self.firstTableView:
let item = self.firstItems[section]
let shouldShowFirstButton = myModel.hasActions(item)
let shouldShowSecondButton = myModel.hasOtherActions(item)
if shouldShowFirstButton && shouldShowSecondButton {
return FirstFooterView.heightForTwoButtons()
} else if shouldShowFirstButton ||shouldShowSecondButton{
return FirstFooterView.heightForOneButton()
} else {
return OtherFooterView.height()
}
case self.secondTableView:
return 0.0
case self.thirdTableView:
if self.state1 {
return 70.0
} else if selectedItem == nil {
return 0.0
}else{
return 0.0
}
default:
DDLogInfo("height 0 for section \(section)")
return 1.0
}
UiView.setAnimationsEnabled(False)
self.TableView.reloadSections(NSIndexSet(index: yoursection),
withRowAnimation: UITableViewRowAnimation.None)
self.TableView.scrollToRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 5),
atScrollPosition: UITableViewScrollPosition.Bottom, animated: false)
UIView.setAnimationsEnabled(true)
使用它您可以重新加载您想要重新加载的特定部分。希望对你有帮助
编辑:如果你想滚动到特定位置
self.TableView.scrollRectToVisible(<#T##rect: CGRect##CGRect#>, animated: <#T##Bool#>)
我想使用 reloadData 刷新部分页脚,但现在除了最后一个部分之外的所有部分都已更新 - 即使页脚可见,也不会调用 viewForFooterInSection。滚动视图是为最后一节调用 viewForFooterInSection 的唯一方法。这种行为的原因可能是什么?我正在使用自动布局。
编辑:实施 heightForFooterInSection 以支持不同的页脚高度,但也许应该只是 return AutomaticDimension 并且逻辑应该放在其他地方?
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
switch(tableView) {
case self.firstTableView:
let item = self.firstItems[section]
let shouldShowFirstButton = myModel.hasActions(item)
let shouldShowSecondButton = myModel.hasOtherActions(item)
if shouldShowFirstButton && shouldShowSecondButton {
return FirstFooterView.heightForTwoButtons()
} else if shouldShowFirstButton ||shouldShowSecondButton{
return FirstFooterView.heightForOneButton()
} else {
return OtherFooterView.height()
}
case self.secondTableView:
return 0.0
case self.thirdTableView:
if self.state1 {
return 70.0
} else if selectedItem == nil {
return 0.0
}else{
return 0.0
}
default:
DDLogInfo("height 0 for section \(section)")
return 1.0
}
UiView.setAnimationsEnabled(False)
self.TableView.reloadSections(NSIndexSet(index: yoursection),
withRowAnimation: UITableViewRowAnimation.None)
self.TableView.scrollToRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 5),
atScrollPosition: UITableViewScrollPosition.Bottom, animated: false)
UIView.setAnimationsEnabled(true)
使用它您可以重新加载您想要重新加载的特定部分。希望对你有帮助
编辑:如果你想滚动到特定位置
self.TableView.scrollRectToVisible(<#T##rect: CGRect##CGRect#>, animated: <#T##Bool#>)