美文网首页
UICollectionViewCell 设置一个选择属性 滚动

UICollectionViewCell 设置一个选择属性 滚动

作者: 何大双 | 来源:发表于2018-11-30 15:54 被阅读0次

项目中遇到一个问题记录一下我的解决方案  如果有好的方案欢迎留言告知必定重谢

状态错乱是cell的重用导致的

//    FilterTermCell *cell = (FilterTermCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"cellId" forIndexPath:indexPath];

改为

    NSString  *cellID =[NSStringstringWithFormat:@"cellId%ld%ld",indexPath.section,indexPath.row];

    FilterTermCell*cell = (FilterTermCell*)[collectionViewdequeueReusableCellWithReuseIdentifier:cellIDforIndexPath:indexPath];

注意cellID需要根据你请求的数据事先registerClass

相关文章

网友评论

      本文标题:UICollectionViewCell 设置一个选择属性 滚动

      本文链接:https://www.haomeiwen.com/subject/nqphcqtx.html