自定义CollectionCell init方法

    xiaoxiao2021-03-25  96

    发现 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; }
    转载请注明原文地址: https://ju.6miu.com/read-23673.html

    最新回复(0)