来源于 一般提问 分类 关于tableViewcell中套collectionview 崩溃

本文分析了一个UITableView单元格内嵌CollectionView导致程序崩溃的问题。详细介绍了崩溃发生的具体位置及错误信息,并探讨了重用标识符不正确配置所带来的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转载自 : http://www.cocoachina.com/bbs/read.php?tid=1706807

关于tableViewcell中套collectionview 崩溃   

- (UICollectionView *)imageCollectView {
    if (!_imageCollectView) {
        UICollectionViewFlowLayout *flowLayot = [[UICollectionViewFlowLayout alloc] init];
        flowLayot.scrollDirection = UICollectionViewScrollDirectionVertical;
        _imageCollectView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, kIphoneWidth, kIphoneHeight) collectionViewLayout:flowLayot];
        _imageCollectView.backgroundColor = kRGBColor(2, 243, 145, 1);
        _imageCollectView.delegate = self;
        _imageCollectView.dataSource = self;
        
        [_imageCollectView registerNib:[UINib nibWithNibName:@"AddImageViewCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:cellString];
        
        [_imageCollectView registerNib:[UINib nibWithNibName:@"PatientImageCollectReuseView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:reuseViewString];
    }
    return _imageCollectView;
}



- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    PatientImageCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellString forIndexPath:indexPath]; 
    程序在这里奔溃
    
    return cell;
}
此方法写在cell中的,没到return 就奔溃了

报错:thread 1 signal sigabrt

奔溃日志:
invalid mode 'kCFRunLoopCommonModes' provided to CFRunLoopRunSpecific - break on _CFRunLoopError_RunCalledWithInvalidMode to debug. This message will only appear once per execution.
libc++abi.dylib: terminate_handler unexpectedly threw an exception

求大神帮忙看看哪里有问题? 


UITableViewCell方法的中的重用问题,需要给每个UITableViewCell赋予一个唯一重用标志符,只允许重用自己,不允许互相重用

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值