Доброго времени суток.
У меня есть CollectionView
, и я бы хотел сделать последнюю ячейку для добавления новых ячеек.
Я делаю это так:
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return media_attachments.count + 1
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if indexPath.row == media_attachments.count {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "media_plus_cell", for: indexPath) as! PlusCell
return cell
} else {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "media_pick_cell", for: indexPath) as! MediaPickCell
cell.media_image.image = media_attachments[indexPath.row].image
if media_attachments[indexPath.row].type == "video"{
cell.media_time.isHidden = false
cell.media_time.text = media_attachments[indexPath.row].duration
} else {
cell.media_time.isHidden = true
}
return cell
}
}
Работает все хорошо до того момента пока в media_attachments
не набирается 2 объекта.
Когда я добавляю 2 объект в коллекцию и обновляю CollectionView
, то ячейка с кнопкой добавить исчезает.
Как сделать ее постоянно статичной?