ios - 我正在使用集合视图,我想在最初加载视图时选择最后一个单元格,稍后用户可以取消选择它
问题描述
我正在使用集合视图,我想在最初加载视图时选择最后一个单元格,稍后用户可以取消选择它我的代码选择了最后一个单元格项目,但后来我无法取消选择它
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: NibConstants.sizeCollectionViewCellIdentifier, for: indexPath) as! SizesFilterationCollectionViewCell
if(indexPath.row == self.mViewModel.collectionViewDumyArray.count - 1){
cell.isSelected = true
cell.sizeLabel.text = self.mViewModel.collectionViewDumyArray[indexPath.row]
}else{cell.sizeLabel.text = self.mViewModel.collectionViewDumyArray[indexPath.row]}
return cell
}
解决方案
推荐阅读
- r - R中的部分字符串匹配将文本统一为一个类别
- java - 使用 lambda 机制在硒中查找元素
- ios - AudioKit 可以在没有 AVAudioEngine 的情况下异步提取 EQed 样本吗?
- reactjs - 从firebase反应读取,得到错误
- javascript - 使用 window.print() 在 Chrome 中显示时如何调整列宽?
- javascript - 在 css 属性“溢出”设置为“自动”的元素的滚动事件上设置 scrollTop/scrollLeft 时会发生什么?
- ios - 设置“视图为”调整情节提要中的帧大小
- c# - 我正在使用 nAudio 库从 MIC 录制,如何增加 MIC 的增益?
- javascript - 如何在前一个结束后启动调度
- ios - 在 ObjectiveC 中安全地传递 bool 值作为参考