首页 > UICollectionViewCell加载问题?

UICollectionViewCell加载问题?

在UIViewController里定义了一个UICollectionView,注册cell

UIViewController.h里面

@property (weak, nonatomic) IBOutlet UICollectionView *pictureCollection;

UIViewController.m里面

[self.pictureCollection registerClass:[CAPictureCell class] forCellWithReuseIdentifier:@"capicture"];

加载cell的代码

-(UICollectionViewCell )collectionView:(UICollectionView )collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{


CAPictureCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"capicture" forIndexPath:indexPath];
if (cell==nil) {
    cell=[[CAPictureCell alloc]init];
}
NSDictionary *dic = [[NSDictionary alloc] init];
[cell setInfo:dic];
return cell;

}

CAPictureCell.m文件里面

想要实现cell

目前只有backgroundColor出来了

求助。


加断点,看setInfo有么有走到


如果你是用 nib/storyboard 做的 cell,不要用:

[self.pictureCollection registerClass:[CAPictureCell class] forCellWithReuseIdentifier:@"capicture"];

而是:

UINib *cellNib = [UINib nibWithNibName:<#Your Nib File#> bundle:nil];
[self.tableView registerNib:cellNib forCellReuseIdentifier:@"capicture"];
【热门文章】
【热门文章】