UIView 没有收到 UICollectionViewDataSource 和 UICollectionViewDelegate 事件

Posted

技术标签:

【中文标题】UIView 没有收到 UICollectionViewDataSource 和 UICollectionViewDelegate 事件【英文标题】:UIView not receive UICollectionViewDataSource and UICollectionViewDelegate event 【发布时间】:2014-12-15 08:30:50 【问题描述】:

我有一个UITableViewCell,其中包含UIView,其中有UICollectionViewUIView 已经实现了UICollectionViewDataSourceUICollectionViewDelegate,但是当我运行UIView 时,不会收到来自UICollectionViewDataSourceUICollectionViewDelegate 的事件。

- (id)init
self = [super init];
if(self)

    [self initBanDau];

return self;


- (void)initBanDau
self.mclv.delegate = self;
self.mclv.dataSource = self;
[self.mclv registerClass:[CellProduct class] forCellWithReuseIdentifier:cellIdentifier];

NSMutableArray改变时,我重新加载UICollectionView的数据

- (void)setMArray:(NSArray *)mArray
if(_mArray)

    [_mArray release];
    _mArray = [mArray retain];

else

    _mArray = [mArray retain];


[self.mclv reloadData];

谁能帮我解释一下。感谢您的帮助!

【问题讨论】:

【参考方案1】:

viewDidLoad:-等不同的方法编写下面的代码:-

self.mclv.delegate = self;
self.mclv.dataSource = self;

【讨论】:

感谢您的帮助!我使用自定义 UIView 实现 UICollectionViewDataSource 和 UICollectionViewDelegate。我将 i 放入 awakeFromNib 但不起作用

以上是关于UIView 没有收到 UICollectionViewDataSource 和 UICollectionViewDelegate 事件的主要内容,如果未能解决你的问题,请参考以下文章

我的自定义 UIView 没有收到触摸

带有 TapGestureRecognizer 的最前面的 UIView 没有收到触摸

Xcode UIView 没有边框颜色等成员

为啥我的 UIView 在重新加载后没有响应?

检查 UIView 当前是不是正在制作动画

UIView touchesCancelled 未调用