首页 > 如何实例化一个collectionview 的cell?

如何实例化一个collectionview 的cell?

let cell = collectionView.dequeueReusableCellWithReuseIdentifier("BigRoomVideoCell", forIndexPath: indexPath) as VideoViewCell

上面是重用cell的写法, 但是如何每次都实例化一个collectionview的cell?

我尝试过 let cell = VideoViewCell()
直接报
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the cell returned from -collectionView:cellForItemAtIndexPath: does not have a reuseIdentifier - cells must be retrieved by calling -dequeueReusableCellWithReuseIdentifier:forIndexPath:

google了也没找到合适的答案


也试过 let cell = collectionView.cellForItemAtIndexPath(indexPath) as VideoViewCell 办法,直接报 fatal error: unexpectedly found nil while unwrapping an Optional value


是否没有注册

    [_collectionView registerClass:[BigRoomVideoCell class]
    forCellWithReuseIdentifier:CELL_IDENTIFIER];
【热门文章】
【热门文章】