小编use*_*214的帖子

UIView容器内的UICollectionView:滚动后不会调用didSelectRowAtIndexPath

我在ViewController中嵌入了3个UIViews Header/Tabar/Container和ScrollView.所以这是我的结构:

在此输入图像描述

在ContainerView中我加载了一个UICollectionView(就像这样):

let controller = storyboard!.instantiateViewControllerWithIdentifier("myCollectionViewController") as! myCollectionViewController
controller.delegate = self

self.addChildViewController(controller)
controller.view.backgroundColor = UIColor.brownColor()
self.containerView.addSubview(controller.view)
controller.didMoveToParentViewController(self)
Run Code Online (Sandbox Code Playgroud)

一切正常,UICollectionView的每个单元都被加载,......唯一的问题是,所有隐藏的单元格(甚至隐藏的单元格的所有部分)都是不可选择的.我的意思是我的函数"didSelectRowAtIndexPath"不适用于第一个屏幕之外的每个像素.这是我的问题的一个方案:

这是我在滚动之前的内容(左边是方案,右边是我在屏幕上实际拥有的内容) - >这里一切正常:

在此输入图像描述

这是滚动后的内容(左边是方案,右边是我在屏幕上实际拥有的内容) - >只有滚动前显示的像素可以调用"didSelectRowAtIndexPath":

在此输入图像描述

问题在于self.view.frame不能很好地刷新.你知道我应该如何更改这个框架以及何时更改?

scroll didselectrowatindexpath ios uicollectionview swift

9
推荐指数
1
解决办法
3735
查看次数