我有我的第二個單元格中的集合視圖的表視圖。從表視圖中的集合視圖執行segue
當收集視圖中的視頻被點擊時,我想執行一個segue到另一個視圖控制器。 enter image description here
我有我的第二個單元格中的集合視圖的表視圖。從表視圖中的集合視圖執行segue
當收集視圖中的視頻被點擊時,我想執行一個segue到另一個視圖控制器。 enter image description here
這就是示例代碼。
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()
}
}
斯威夫特版本使用的是?以及「self」的類型是什麼? – Mina
確定您已將'collectionview'委託添加到UITableviewCell, 嘗試在'cellforrowatindextpath'中設置'collectionview'委託並將該方法放入'Viewcontroller'中。它會工作 –
@mina即時通訊使用swift 3.自我意圖被刪除,即時通訊只是試圖推動到另一個控制器時,收集視圖單元格,這是在表格視圖cel,被選中。 – GRattab