我不使用 Storyboard。我只用代码编写它。
我想知道如何点击collectionviewcell进行转换。
项目 View 重叠如下。
/*每个 View 的颜色
VC(绿色)
baseTableV(红色)
UItableViewCell
↓
HogeUIView(灰色)
表V(蓝色)
UItableViewCell
↓
orangeView(橙色)
baseColle(紫色)
Page0Cell(黄色)
↓
表V(灰色)
UItableViewCell//我想点击这个单元格来进行转换。但我不能。
*/
我会问一下不能通过点击进行转换。
我想看看。请。 谢谢。
最佳答案
您只是缺少一个 VC 实例。在您的 OrangeView 类中添加以下内容:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ColleCellId0, for: indexPath) as? Page0Cell
cell?.vc = vc
return cell!
}
但是,我不会这样做。我更喜欢使用代表。这是您如何做到这一点的示例。
https://github.com/galots/test1126-master
我用//HERE//标记了您需要添加的所有委托(delegate)代码,以便您可以轻松找到它们。祝你好运
关于swift - 点击 UICollectionViewCell 不会转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53457747/