1つのコレクションビュー内に2つのセルがあります。それらはどちらも異なるディメンションを持ちますが、何らかの理由で実行時に両方のセルが同じディメンションを持つように見えます。ここで異なる次元の単一CollectionView内の2つのセル
は私の設定です:
internal func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if cellType == .books {
return books.count
} else if cellType == .spotlights {
return spotlights.count
} else {
return 0
}
}
internal func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if cellType == .books {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "booksCollectionCell", for: indexPath) as! BooksCollectionCell
let bookTitle = books[indexPath.item].title
let authors = books[indexPath.item].authors
cell.configureCell(title: bookTitle, authorNames: authors)
return cell
} else {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "spotlightsCollectionCell", for: indexPath) as! spotlightsCollectionViewCell
cell.configureCell(image: #imageLiteral(resourceName: "testImage"))
return cell
}
}
は、ここに私のストーリーボードのスクリーンショットです:
、これはcollectionViewのセットアップです:
編集:だから私は、管理対象somwhを取得するERE cellForItemにこのコードを入れて(cpatmulloyのおかげ):
cell.frame = CGRect(x: cell.frame.origin.x, y: cell.frame.origin.y, width: 180.0, height: 130.0)
は、しかし、ここでの結果は、(テーブルビューの最後のセルを見て)です:
をこれらが得る専用のプロパティです... –
私が行った編集内容を確認してください^ – cpatmulloy
は違いのビットを作ったが、今セルが重複しています –