首页 > 其他 > 详细

UICollectionViewCell 所遇到的问题

时间:2015-05-10 16:56:38      阅读:252      评论:0      收藏:0      [点我收藏+]

刚开始学习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了。

 

UICollectionViewCell 所遇到的问题

原文:http://www.cnblogs.com/txq520/p/4492413.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!