0
我创建了一个简单的应用程序,并将其拖动到一个UICollectionView
上。有一个单元格,我给它一个单元格ID并为其添加标签。我也改变了collectionview
和单元的背景颜色。 当我在模拟器中运行应用程序时,collectionview
在那里,但单元格不在。 我不知道我在做什么错我开始变得非常生气。UICollectionView内置IB,不显示单元格
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;
}
@ user1089677你有没有检查IB的数据源和集合视图的委托? –
谢谢!我一直在寻找太久的答案,并最终导致了这种情况。 – user1086377