有人可以告訴我為什么我的收藏視圖是這樣堆疊而不是并排的(直到沒有更多空間并且必須開始新行)?我不希望它們每行只有一個堆疊。

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
claimSections.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionViewCell", for: indexPath) as? ClaimTypeCollectionCell else {return UICollectionViewCell()}
cell.claimTypeCollectionImage.image = claimSectionImages[indexPath.row]
cell.claimTypeCollectionLabel.text = claimSections[indexPath.row]
cell.frame.size.height = 135
cell.frame.size.width = 135
cell.layer.borderWidth = 2
cell.layer.borderColor = UIColor.black.cgColor
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if indexPath.row == 0 {
// The Auto button was tapped -> load the auto page
modelController.theClaimType = "Auto"
modelController.isANewFile = true
performSegue(withIdentifier: "claimTypeToFileSetupSegue", sender: self)
} else {
SCLAlertView().showNotice("COMING SOON!", subTitle: "This section is not yet available. It will be soon!")
}
}
uj5u.com熱心網友回復:

滾動方向 -> 水平
uj5u.com熱心網友回復:
要在您的 collectionViewCells 上安排自動布局,您必須在您的集合視圖上修改 flowLayout 并設定單元格的大小。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/420328.html
標籤:
上一篇:實體狀態未更新——SwiftUI
