У меня есть две ячейки в пределах одного вида коллекции. Оба они имеют разные размеры, но по какой-то причине во время выполнения обе ячейки имеют одинаковое измерение.Две ячейки в одном CollectionView разных размеров
Вот мои настройки:
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 (благодаря cpatmulloy), поместив этот код в cellForItem:
cell.frame = CGRect(x: cell.frame.origin.x, y: cell.frame.origin.y, width: 180.0, height: 130.0)
Однако вот результат (посмотрите на последнюю ячейку в Tableview):
это получить свойства только ... –
Пожалуйста, проверьте изменения, которые я сделал^ – cpatmulloy
сделал немного разницы, но теперь ячейки перекрываются –