ios - UICollectionViewCell加载问题?
怪我咯
怪我咯 2017-04-18 09:03:51
[iOS讨论组]

在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文件里面

  • (void)setInfo:(NSDictionary*)d{

    self.backgroundColor = [UIColor redColor];
    [self.CAPicture setImage:[UIImage imageNamed:@"logoGrey.png"]];
    self.CALabel.text = @"222";

    }

想要实现cell

目前只有backgroundColor出来了

求助。

怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复(2)
ringa_lee

加断点,看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"];
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号