作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
一个部分可能包含 1 个页眉、许多内容项和 1 个页脚。
对于 DiffableDataSource
,网上的大部分例子,都是用的enum
代表科。例如
func applySnapshot(_ animatingDifferences: Bool) {
var snapshot = Snapshot()
snapshot.appendSections([.MainAsEnum])
snapshot.appendItems(filteredTabInfos, toSection: .MainAsEnum)
dataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
}
但是,当 Section 有动态内容页脚时,我们可能需要使用 struct 来表示 Section。例如
import Foundation
struct TabInfoSection {
// Do not include content items [TabInfo] as member of Section. If not, any mutable
// operation performed on content items, will misguide Diff framework to throw
// away entire current Section, and replace it with new Section. This causes
// flickering effect.
var footer: String
}
extension TabInfoSection: Hashable {
}
但是,我们如何假设只更新页脚?
class TabInfoSettingsController: UIViewController {
…
func applySnapshot(_ animatingDifferences: Bool) {
var snapshot = Snapshot()
let section = tabInfoSection;
snapshot.appendSections([section])
snapshot.appendItems(filteredTabInfos, toSection: section)
dataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
}
var footerValue = 100
extension TabInfoSettingsController: TabInfoSettingsItemCellDelegate {
func crossButtonClick(_ sender: UIButton) {
let hitPoint = (sender as AnyObject).convert(CGPoint.zero, to: collectionView)
if let indexPath = collectionView.indexPathForItem(at: hitPoint) {
// use indexPath to get needed data
footerValue = footerValue + 1
tabInfoSection.footer = String(footerValue)
//
// Perform UI updating.
//
applySnapshot(true)
}
}
}
我会得到以下闪烁的结果。
TabInfoSection
有变化。目的。
DiffableDataSource
更新 Section 中的页脚不会造成闪烁效果?
最佳答案
你有没有想过只为页脚制作一个部分?这样一来,当它闪烁时就不会重新加载,因为它在技术上不属于有问题的部分?
关于ios - 如何通过DiffableDataSource更新Section中的页脚而不会造成闪烁效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64326881/
我是一个使用 Python 和 PyGTK 的 Linux 软件项目的开发人员。我们正在编写的程序依赖于许多第三方包,这些包可通过所有 mayor 发行版存储库获得。其中之一是 python 绑定(b
我是一名优秀的程序员,十分优秀!