2017-06-17 82 views
-1

我有我的第二個單元格中的集合視圖的表視圖。從表視圖中的集合視圖執行segue

當收集視圖中的視頻被點擊時,我想執行一個segue到另一個視圖控制器。 enter image description here

+0

斯威夫特版本使用的是?以及「self」的類型是什麼? – Mina

+0

確定您已將'collectionview'委託添加到UITableviewCell, 嘗試在'cellforrowatindextpath'中設置'collectionview'委託並將該方法放入'Viewcontroller'中。它會工作 –

+0

@mina即時通訊使用swift 3.自我意圖被刪除,即時通訊只是試圖推動到另一個控制器時,收集視圖單元格,這是在表格視圖cel,被選中。 – GRattab

回答

-1

這就是示例代碼。

class tableViewClass: UIViewController, UITableViewDelegate, UITableViewDataSource, VideoCellSelectionDelegate { 
    @IBOutlet weak var tableView: UITableView! 

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
     return 1 
    } 

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 
     let cell = tableView.dequeueReusableCell(withIdentifier: "VideoCell", for: indexPath) as! VideoCell 
     cell.delegate = self 
     return cell 
    } 

    func didSelect() { 
     //performSegue 
    } 

} 

VideoCell必須有一個被稱爲委託時的CollectionView細胞是選擇

protocol VideoCellSelectionDelegate { 
    func didSelect() 
} 

class VideoCell: UITableViewCell, UICollectionViewDelegate { 
    var delegate: VideoCellSelectionDelegate? 

    @IBOutlet weak var collectionView: UICollectionView! 

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 
     delegate?.didSelect() 
    } 

} 
+0

我添加了這段代碼我的集合視圖已經消失 – GRattab

+0

你只需要添加委託部分進入你的項目。所有其他人都只是示例代碼,我只是想讓你看看你如何以及在哪裏使用代表。 – Mina