ios - UICollectionView 补充视图初始化在滚动时被一遍又一遍地调用
问题描述
在我的 UICollectionView 中,我有一个补充标题。一开始一切正常,然后当我使用该应用程序时,看起来我的标题单元格中的 init 方法在我每次滚动它时开始被调用,并且它变得滞后。我可以说出一些错误,因为每次我像这样滚动它时,我的标题内视图上的阴影开始再次附加
这是我设置标题的地方
switch kind {
case UICollectionView.elementKindSectionHeader:
let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "feeds", for: indexPath) as! ChangeFeedCell
header.feedsButton.addTarget(self, action: #selector(showFeeds), for: .touchUpInside)
header.typeButtonWhole.addTarget(self, action: #selector(changeFeeds), for: .touchUpInside)
header.topButtonWhole.addTarget(self, action: #selector(changeTopSort), for: .touchUpInside)
feedLabelsDelegate = header
return header
case UICollectionView.elementKindSectionFooter:
let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "Footer", for: indexPath) as! LoadingFooterCell
showLoaderDelegate = footer
footer.backgroundColor = .clear
return footer
default:
fatalError("Unexpected element kind")
}
解决方案
推荐阅读
- c - 如果不使用 const,则在 RAM 中进行不需要的分配,尽管放置在 Flash 绝对地址
- java - Java:如何从块中的 ArrayList 中的目录加载所有文件并处理它
- openedx - open edx中lms admin和cms admin的区别
- pentaho - Pentaho:条形图颜色根据定义的参数
- node.js - Nodejs保存JSON文件
- spring - 403 Forbidden while doing delete request. Spring Boot 休息 api
- angular - 如何在角度 service.ts 中传递修复变量?
- spring - 登录尝试期间的Spring安全异常
- sql - 选择字符串值并转换/转换为日期
- javascript - 如何模拟在函数外部实例化的常量?