我正在用Swift开发一个iOS应用程序。
我已经创建了一个UICollectionViewController。我已经用图像填充了UICollectionViewCells。例如,如果我点击第一个单元格,它们将显示下一个ViewController (但是新的ViewController不需要来自单元格的数据,内容就完全不同了)。我只会让他们打开下一个视图控制器,这对UiCollectionView中的每个图像都是这样。
使用prepareforsegue,我有一个问题:当我点击同一ViewController显示的每一张图像时。我希望每个图像打开一个不同的新ViewController。我需要什么功能?
发布于 2016-06-26 14:17:53
定义它们要转换到的viewController。如果每个单元格需要转到不同的viewController,那么每个单元格都需要一个segue。
UICollectionViewController的顶部,而不是从原型单元格:

collectionView(_:didSelectItemAtIndexPath:)中,使用indexPath选择正确的segue标识符并调用performSegueWithIdentifier(_:sender:):
重写func collectionView(collectionView: UICollectionView,didSelectItemAtIndexPath indexPath: NSIndexPath) { let segue= "goToVC1","goToVC2","goToVC3“let segueID = seguesindexPath.item performSegueWithIdentifier(segueID,发件人: self) }https://stackoverflow.com/questions/38039284
复制相似问题