0

UITableViewと Inside があり、2つ持っていますUICollectionViews

私の要件は、最初にUICollectionView水平方向にスクロールする必要があることです。そして、スクロールUITableViewしたくないので、垂直にスクロールする必要があります Second UICollectionView.

Image では、最初 (Header 'Folder')UICollectionViewを水平方向にスクロールする必要があり、2 番目 (Header 'Product')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の高さを設定するにはどうすればよいですか?

4

1 に答える 1