0
我使用xib(MyCustomCell.xib)创建了自定义UICollectionViewCell(我们称之为MyCustomCell),并且我想创建MyCustomCell的一个子类(我们称之为MyCustomCell2)。 MyCustomCell2(MyCustomCell)的父级有一个名为titleLabel的IBOutlet。然而,对于titleLabel总是MyCustomCell2返回nil即使我做子类化从xib创建的自定义视图
self.collectionView.
registerClass(MyCustomCell2.self, forCellWithReuseIdentifier: cellIdentifier);
在viewDidLoad中
和
let cell = collectionView.
dequeueReusableCellWithReuseIdentifier(cellIdentifier, forIndexPath: indexPath) as! MyCustomCell2;
中的cellForRowAtIndexPath
任何在这个问题上是什么样的想法?
但MyCustomCell与MyCustomCell2有不同的cellIdentifier,所以不会registerClass:cellReuseIdentifier导致崩溃? – user3808735
@ user3808735你需要使用registerNib。并且您需要注册连接插座的笔尖 –