UICollection Cell不是从零索引开始的新部分

我写了一个代码来显示不同部分的单元格。但是,当我运行代码时,在新的部分中,单元格位于显示上一个单元格的位置的下一个位置。

let cell: EPOSProductCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "productCell",for: indexPath) as! EPOSProductCollectionViewCell

cell.productImage.loadImageUsingCacheWithUrlString(urlString: menuResponse?.data?[indexPath.section].products?[indexPath.item].image ?? "") 
cell.productName.text = menuResponse?.data?[indexPath.section].products?[indexPath.item].name ?? ""

if menuResponse?.data?[indexPath.section].products?[indexPath.item].spiceLevel != nil {
    // ...
} else {
    cell.spiceLevelIcon.isHidden = true
}

return cell

对于部分,我的代码如下:

let sectionHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind,withReuseIdentifier: "sectionHeader",for: indexPath) as! EPOSMenuCollectionReusableView
sectionHeader.sectionHeaderTitle.text = menuResponse?.data[indexPath.section].name

return sectionHeader

该部分是从情节提要中创建的

此问题仅在横向模式下出现,并且仅在任何给定部分中有一个项目时出现。

Here is the picture for understanding the issue

windfour 回答:UICollection Cell不是从零索引开始的新部分

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3152256.html

大家都在问