点击 UICollectionViewCell 不会过渡 [英] Tap on UICollectionViewCell does not transition

查看:17
本文介绍了点击 UICollectionViewCell 不会过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不使用故事板.我只用代码编写.

I do not use the storyboard. I write it with code only.

我想知道如何点击 collectionviewcell 进行转换.

I would like to know how to tap collectionviewcell to make a transition.

项目视图重叠如下.

/*每个视图的颜色

VC(绿色)

baseTableV(红色)

baseTableV (red)

UItableViewCell

UItableViewCell

HogeUIView(灰色)

HogeUIView (gray)

tableV(蓝色)

UItableViewCell

UItableViewCell

orangeView(orange)

orangeView(orange)

baseColle(紫色)

baseColle (purple)

Page0Cell(黄色)

Page0Cell (yellow)

tableV(灰色)

UItableViewCell//我想点击这个单元格进行过渡.但我不能.

UItableViewCell //I want to tap this cell to make a transition. But I can not.

*/

我会问不能通过点击转换.

I will ask about that can not be transitioned by tapping.

我想看看.请.谢谢.

推荐答案

您只是缺少一个 VC 实例.在您的 OrangeView 类中添加:

You are just missing one instance of the VC. In your OrangeView class add this:

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ColleCellId0, for: indexPath) as? Page0Cell
    cell?.vc = vc
    return cell!
}

但是,我不会这样做.我更喜欢使用委托.这是您如何做到的示例.

However, I wouldn't do it like this. I would prefer to use delegates. Here is and example of how you could it.

https://github.com/galots/test1126-master

我用//HERE//标记了您需要添加的所有委托代码,以便您可以轻松找到它们.祝你好运

I marked all the delegate code that you need to add with // HERE // so you can find them easily. Good luck

这篇关于点击 UICollectionViewCell 不会过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆