在这里,您将
didSelectItemAtIndexPath在
CategoryRow类上的委托方法上单击单元格,然后可以在其中触发委托以在
ViewController
ViewController.swift 内部进行调用:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! CategoryRow cell.delegate = self return cell }VideoCell.swift :
protocol CategoryRowDelegate:class { func cellTapped() }CategoryRow.swift :
class CategoryRow : UITableViewCell { weak var delegate:CategoryRowDelegate? @IBOutlet weak var collectionView: UICollectionView! } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { if delegate!= nil { delegate?.cellTapped() } }在内部添加委托函数
ViewController
func cellTapped(){//pre for navigation}


