簡體   English   中英

UITableViewCell內的UICollectionView

[英]UICollectionView inside a UITableViewCell

我想在我的viewcontroller中實現一個函數,該函數包含一個UITableView ,而TableViewCell包含一個CollectionView

我想用用戶按下的選定CollectionViewCell初始化一個函數,但是我不知道如何區分用戶選擇的是哪個單元格,

現在,我使用我的prepareForSegue

  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    switch segue.identifier {
    case "SelectedDish"?:
        let myVC = segue.destination as! SelectedDishViewController
          if let indexPath = my_table_view.indexPathForSelectedRow . // this will tell me what cell in the table view the user chose a collectionViewcell
          {
 // here I want to get the index of the collectionViewCell inside the tableview.

    default:
        break
    }
}

有沒有其他方法可以實現這一目標?

我設法解決我的問題,

我在collecitonview的每個單元格中隱藏了一個按鈕,每個單元格都有一個分區號,即tableview單元格indexpath.row,我為設置每個單元格的每個collectionview單元格分配一個索引,當按下按鈕時,我存儲集合視圖單元格的部分和索引,然后在准備segue時使用它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM