目前,我们有一个在" didSelectItemAt indexPath"它位于collectionViewCell上。它是这样做的,以便将collectionViewCell嵌入tableViewCell中,以便它可以侧滚动。当按下collectionViewCell时,它应该转到另一个视图控制器。截至目前,从未调用过与该协议相关联的单元的viewController。这是代码:
protocol handleKnownForImage {
func knownForImageTapped(movieID: NSNumber)
}
//On TableViewCell
class KnownForCell : UITableViewCell {
var imageDelegete: handleKnownForImage?
var movieID: NSNumber?
}
extension KnownForCell: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
print("Known For Cell Has Been Pressed")
self.movieID = knownForExtendedArray[indexPath.row].id
guard let movieID = movieID else {return}
imageDelegete?.knownForImageTapped(movieID: movieID)//This gets called
}
}
//On ViewController
extension PeopleDetailViewController: handleKnownForImage {
var knownForID: NSNumber?
func knownForImageTapped(movieID: NSNumber) {//This is never called
self.knownForID = movieID
performSegue(withIdentifier: peopleToDetailSegue, sender: self)
}
}