博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UICollectionViewCell 所遇到的问题
阅读量:4490 次
发布时间:2019-06-08

本文共 977 字,大约阅读时间需要 3 分钟。

刚开始学习iOS开发,今天用到了UICollectionView,遇到了点问题。

自定义了一个PortalViewCell,当然继承于UICollectionViewCell,然后在故事版中把它和cell关联起来。

PortalViewCell中提供了一个公有方法:

-(void) setupCellView;

 

接着在 cellForItemAtIndexPath中编写:

1 - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {2     PortalViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];3     [cell setupCellView];4   5     return cell;6 }

 

编译完成,正确无误,运行起来 duang~挂掉了,报错信息

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionViewCell setupCellView]: unrecognized selector sent to instance 0x7fd7535df8c0'

找了好久,没天理啊,PortalViewaCell有这个方法啊!!!!!又看了看发现viewDidLoad中有这么一句话:

// Register cell classes     [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];

这是搞什么?注册cell类?删掉,重新运行就OK了。

 

转载于:https://www.cnblogs.com/txq520/p/4492413.html

你可能感兴趣的文章
《构建之法》(五)
查看>>
创建django项目
查看>>
Linux Bash基本功能
查看>>
一则小脚本(工作中用)
查看>>
软件工程结对作业
查看>>
Keil 4.0 生成bin文件
查看>>
sql语句的进化--hibernate篇
查看>>
python爬虫之cookie
查看>>
2017年5月29号课堂笔记
查看>>
HDU4247【瞎搞】
查看>>
lightoj 1125【背包·从n个选m个】
查看>>
HDU 1243 反恐训练营(最长公共序列)
查看>>
mysql数据库隔离级别
查看>>
(六)buildroot使用详解
查看>>
chrome修改UserAgent,调试
查看>>
Source Insight4.0 试用。。试用。。试用。。
查看>>
python循环for,range,xrange;while
查看>>
解决Ueditor在bootstarp 模态框中全屏问题
查看>>
POJ 1006 Biorhythms
查看>>
dubbo+zookeeper注册服务报错问题:No service registed on zookeeper
查看>>