collectionViewCell防止复用的两种方法
2016-11-28 17:49
2963 查看
collectionView 防止cell复用的方法
一:
//在创建collectionView的时候注册cell(一个分区)
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@“cell" forIndexPath:indexPath];
for (UIView *view in cell.contentView.subviews) {
[view removeFromSuperview];
}
二:
//在cellForItem方法中注册cell(多个分区)
NSString *identifier=[NSString stringWithFormat:@"%ld%ld",(long)indexPath.section,(long)indexPath.row];
[collect registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:identifier];
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
for(id subView in cell.contentView.subviews){
if(subView){
[subView removeFromSuperview];
}
}
一:
//在创建collectionView的时候注册cell(一个分区)
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@“cell" forIndexPath:indexPath];
for (UIView *view in cell.contentView.subviews) {
[view removeFromSuperview];
}
二:
//在cellForItem方法中注册cell(多个分区)
NSString *identifier=[NSString stringWithFormat:@"%ld%ld",(long)indexPath.section,(long)indexPath.row];
[collect registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:identifier];
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
for(id subView in cell.contentView.subviews){
if(subView){
[subView removeFromSuperview];
}
}
相关文章推荐
- IOS collectionViewCell防止复用的两种方法
- collectionView 防止cell复用的方法
- 关于collectionView和tableView的两种cell的出列方法的区别
- 关于collectionView和tableView的两种cell的出列方法的区别
- 关于UITableView的cell复用问题的3种解决方法
- collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath 方法不调用
- 当cell很少的情况下(没有占满屏幕),不能拖拽collectionView进行下拉刷新,解决方法
- iOS-UITableView的两种重用Cell方法的区别(dequeueReusableCellWithIdentifier)
- 纯代码写CollectionViewCell的复用问题
- TableView 或者collectionView 获取点击的cell 和当前行数的方法
- 给tableview Cell添加动画(两种实现方法 效果还不错)
- UICollectionView - 调用delegate定义item大小后不调用collectionView:cellForItemAtIndexPath:函数的解决方法
- iOS-UITableView的两种重用Cell方法的区别(dequeueReusableCellWithIdentifier)
- iOS UItableview的两种重用cell的方法的区别
- 纯代码写CollectionViewCell的复用问题
- UITableView的两种重用Cell方法的区别
- CollectionViewCell 不执行 cellForItemAtIndexPath 方法的问
- Swift3.0 自定义tableView复用cell 的写法,与CollectionViewCell的不同,数据model
- 学习笔记一:UIImage初始化方法以及点击UICollectionView和遇到点击的TableViewCell
- UICollectionViewCell复用时修改子页面属性出现混乱的解决方法