【发布时间】:2019-04-12 20:18:49
【问题描述】:
我在 collectionView 中有一个 collectionView,我希望能够在第二个 collectionView 中选择一个单元格来执行对另一个 ViewController 的 segue。
目前,当我选择一个单元格时,我收到以下消息: " Receiver ... 没有带有标识符 'ToVC2' 的 segue。"
但是,我已经从其他 UIButtons 中使用了这个 segue/标识符,并且它可以工作。
我有两个 ViewController:ViewController1 和 ViewController2。
在 ViewController1 上,有一个具有垂直滚动功能的 collectionView(“categoryCollectionView”)。
在 categoryCollectionView 中,还有另一个允许水平滚动的 collectionView(“eventCollectionView”)。
对于 numberOfItemsInSection 和 cellForItemAt,两个 collectionView 已设置并正常工作。我现在希望能够在 eventCollectionView 中选择一个单元格,并导致从 ViewController1 到 ViewController2 的 segue。
我在 ViewController1 中添加了一个函数:
func segueToViewController2(event: Event){
performSegue(withIdentifier: "ToVC2", sender: event)
}
在 eventCollectionView 的 didSelectItemAt 中,我尝试了以下方法:
var viewController1: ViewController1? = ViewController1()
viewController1.segueToViewController2(event: eventSelected)
当我选择一个单元格时,我收到以下错误消息:
'Receiver() 没有标识符为'ToVC2'的segue'
但是,如果从 ViewController1 上的常规 UIButton 调用此函数会正确执行转场(因此我知道问题不在于没有转场/标识符错误。)我认为问题在于正在调用该函数来自 collectionView 中的 collectionView。
请帮忙!!!!!!
【问题讨论】:
标签: swift xcode uicollectionview segue uicollectionviewcell