ios collectionviewcell防止复用的两种方法
collectionview 防止cell复用的方法一:
//在创建collectionview的时候注册cell(一个分区) uicollectionviewcell *cell=[collectionview dequeuereusablecellwithreuseidentifier:@“cell" forindexpath:indexpath]; for (uiview *view in cell.contentview.subviews) { [view removefromsuperview]; }
collectionview 防止cell复用的方法二:
//在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]; } }
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
如对本文有疑问, 点击进行留言回复!!
HDU - 5532 A - Almost Sorted Array
react native 实现扫描条形码功能(react-native-camera)
网友评论