У меня есть UITableView, и внутри у меня есть два UICollectionViews
.
Мое требование состоит в том, что я должен сначала прокручивать UICollectionView
по горизонтали. И я должен прокручивать UITableView
по вертикали, потому что я не хочу прокручивать второй UICollectionView
.
На изображении вы можете видеть, что первое (Заголовок «Папка») UICollectionView
Мне нужно прокручивать горизонтально, а второе (Заголовок «Продукт») UICollectionView
Я не хочу прокручивать вертикально, потому что мне нужно прокручивать «Завершить» UITableView
.
Оба collectionView
находятся в TableViewCell
, и я отключил прокрутку второго UICollectionView
.
Мне нужно добавить и удалить продукт, а затем я могу установить высоту ячейки TableViewSecond
, на которую должен поступать контент.
Вот мой код:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (0 == indexPath.section) {
var addFolderCell = tableView.dequeueReusableCell(withIdentifier: "AddFolderCell") as? AddFolderCell
if(nil == addFolderCell) {
let nib:Array = Bundle.main.loadNibNamed("AddFolderCell", owner: self, options: nil)!
addFolderCell = nib[0] as? AddFolderCell
}
addFolderCell?.collectionView.delegate = self
addFolderCell?.collectionView.dataSource = self
return addFolderCell!
} else {
let identifier = "CreateFolderCell"
var createFolderCell = tableView.dequeueReusableCell(withIdentifier: identifier) as? CreateFolderCell
if(createFolderCell == nil) {
let nib:Array = Bundle.main.loadNibNamed("CreateFolderCell", owner: self, options: nil)!
createFolderCell = nib[0] as? CreateFolderCell
}
return createFolderCell!
}
}
//Height for row.
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
//let index : NSIndexPath = NSIndexPath(row: 0, section: 1)
if 0 == indexPath.section {
return 135
}
return 300
}
// Высота заголовка.
func tableView(_ tableView: UITableView, estimatedHeightForHeaderInSection section: Int) -> CGFloat {
return 20
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return sectionsArray[section] as? String
}
}
extension GroupDataView : UICollectionViewDelegate,UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 4
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "AddFolderCollectionCell", for: indexPath) as! AddFolderCollectionCell
//cell.backgroundColor = UIColor.white
cell.layer.borderWidth = 0.4
cell.layer.borderColor = UIColor.lightGray.cgColor
cell.layer.cornerRadius = 2
//CreateCardView(viewCorner: cell.cardView) //cell.cardView
return cell
}
}
//MARK: Макет просмотра коллекции
extension GroupDataView : UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: 90, height: 130)
}
}
Что я могу сделать? Как я могу установить высоту для tableView?