自定义CollectionCell init方法

来源:互联网 发布:java发牌器 编辑:程序博客网 时间:2024/05/02 00:10

发现 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;}
0 0