UICollectionView 不调用委托方法 [英] UICollectionView doesn't call delegate methods
问题描述
我在故事板中设置了一个 UICollectionView
并连接了数据源和委托插座.我已经通过 nib 注册了一个单元,我在 cellForItemAtIndexPath:
方法中出列.
I've setup a UICollectionView
in a storyboard and connected the dataSource and delegate outlets. I've registered a cell via nib which I dequeue in the cellForItemAtIndexPath:
method.
所有工作都完美地期望永远不会调用委托方法.例如:当触摸一个单元格时,我希望 didSelectItemAtIndexPath:
被调用.
All works perfectly expect that the delegate methods are never called. For example: When touching on a cell, I expect the didSelectItemAtIndexPath:
to be called.
我已经仔细检查了集合视图的委托 - 它已正确分配.
I've double-checked the delegate of the collection view - it's assigned correctly.
有谁知道不调用方法的原因吗?
Does anybody know the reason why the methods are not called?
推荐答案
这完全是我的错.我在前面添加了一个透明的子视图,它消耗了触摸 - 一个非常严重的错误.
It's completely my fault. I've added a transparent subview to the front which consumes the touches - a really bad mistake.
这篇关于UICollectionView 不调用委托方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!