如何解决具有多个部分的collectionview上的ReloadSections
我正在尝试动画化collectionView中多个部分的重新加载
self.collectionView.performBatchUpdates({
let updatedSections = Array(0...(self.viewModel?.numberOfSections ?? 0))
self.collectionView.reloadSections(updatedSections)
},completion: nil)
错误:无法将类型[Int]的值转换为预期的参数类型 'IndexSet'
解决方法
就像错误状态一样,当函数需要参数类型为[Int]
的参数时,您将传递一个整数数组,即IndexSet
您可以像对IndexSet
那样用一系列整数初始化Array
替换:
let updatedSections = Array(0...(self.viewModel?.numberOfSections ?? 0))
self.collectionView.reloadSections(updatedSections)
具有:
self.collectionView.reloadSections(IndexSet(integersIn: 0...(self.viewModel?.numberOfSections ?? 0)))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。