1
下午好,prepareForSegue永远不会在UICollectionView称为
我想从我的CollectionView进行赛格瑞但触摸池时,prepareForSegue永远不会触发。这适用于我的TableView,但它不适用于我的CollectionView。
正如你可以在我的代码中看到的,我有两个在同一个ViewController,但我不知道为什么它只适用于TableView。 “segueCollection”永远不会被触发。
为了完成这项工作我需要做些什么?有一些类型的问题,因为我也使用TableView segue?我在这里有点迷路了。
这里是我的代码:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showMovieFromTable", let destination = segue.destinationViewController as? MovieViewController, index = tableView.indexPathForSelectedRow?.row {
destination.year = searchMovies[index].year
} else if segue.identifier == "showMovieFromCollection" {
print("segueCollection")
}
print("segueTriggered")
}
我也在这里面的代码试图(但它也没有显示任何东西):
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
print(indexPath)
self.performSegueWithIdentifier("showMovieFromCollection", sender: self)
}
由于提前,
问候。
“为了使这项工作我需要做什么?”是的,让我们知道。你如何连接到集合 –
我@Lu_,我已经将CollectionViewCell中的Cell的“选择”选项连接到Storyboard中的MovieViewController。 –
你在哪里叫它('performSegue :())'?你是怎么设定的?例如,如果将segue直接从单元格放到下一个VC,而不是当前的VC到下一个VC,则不会调用它。 – Larme