发现 collectionVIew 的dequeue方法指定的是initWithFrame:
方法,即如果重用找不到只会调用initWithFrame:(CGRect)frame
方法,init
方法根本不会调用,原因未知 T-T
又了解的吗,麻烦告知一下
[collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath]
- (instancetype)init
{
self = [super init];
if (self) {
self.backgroundColor = [UIColor redColor];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor greenColor];
}
return self;
}