UICollectionView 中的 iOS 断言失败 [英] iOS Assertion Failure in UICollectionView

查看:19
本文介绍了UICollectionView 中的 iOS 断言失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了错误...

*** Assertion failure in -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:], /SourceCache/UIKit/UIKit-2372/UICollectionView.m:2249

尝试显示 UICollectionView 时.

When trying to display a UICollectionView.

导致它的行是......

The lines causing it are...

static NSString *CellIdentifier = @"Cell";

UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];

出队发生错误.

没有其他错误,所以我很难知道从哪里开始.

There are no other errors so I'm struggling to know where to begin with this.

有人能解释一下吗?

推荐答案

一直在阅读文档(可能应该先这样做:))

Been reading the docs (should possibly have done this first :) )

无论如何,我正在使用的 collectionView 位于单独的 xib 文件(不是故事板)中,并且来自文档...

Anyway, the collectionView I am using is within a separate xib file (not a storyboard) and from the docs...

Important: You must register a class or nib file using the
registerClass:forCellWithReuseIdentifier: or
registerNib:forCellWithReuseIdentifier: method before calling this method.

谢谢

这篇关于UICollectionView 中的 iOS 断言失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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