UICollectionView 内置 IB 不显示单元格
UICollectionView Built in IB not displaying cell
我创建了一个简单的应用程序并将 UICollectionView
拖到上面。有一个单元格,我给它一个单元格 ID 并为其添加了一个标签。我还更改了 collectionview
和单元格的背景颜色。
当我 运行 模拟器中的应用程序时, collectionview
存在但单元格不存在。
我不知道我做错了什么,我真的开始生气了。
class ViewController: UIViewController, APExpandingTextViewDelegate,UICollectionViewDataSource,UICollectionViewDelegate {
...
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1;
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! UICollectionViewCell
return cell;
}
什么都没有出现。
IB的屏幕截图
检查故事板中的数据源和集合视图的委托是否已连接。
我创建了一个简单的应用程序并将 UICollectionView
拖到上面。有一个单元格,我给它一个单元格 ID 并为其添加了一个标签。我还更改了 collectionview
和单元格的背景颜色。
当我 运行 模拟器中的应用程序时, collectionview
存在但单元格不存在。
我不知道我做错了什么,我真的开始生气了。
class ViewController: UIViewController, APExpandingTextViewDelegate,UICollectionViewDataSource,UICollectionViewDelegate {
...
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 1;
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as! UICollectionViewCell
return cell;
}
什么都没有出现。
IB的屏幕截图
检查故事板中的数据源和集合视图的委托是否已连接。