国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

UICollectionViewCell復用時修改子頁面屬性出現混亂的解決方法

2019-11-09 18:41:46
字體:
來源:轉載
供稿:網友

這個方法就是給每一個cell一個唯一的標識符,正常情況下重用cell,給cell的一些子視圖賦值時不會發生cell重用混亂問題,但是在修改cell子視圖的屬性的時候就會發生cell復用的混亂。下面是代碼片段

[objc] view plain copy PRint?在CODE上查看代碼片// 每次先從字典中根據IndexPath取出唯一標識符,避免復用  NSString *identifier = [_cellDic objectForKey:[NSString stringWithFormat:@"%@", indexPath]];  // 如果取出的唯一標示符不存在,則初始化唯一標示符,并將其存入字典中,對應唯一標示符注冊Cell  if (identifier == nil) {        identifier = [NSString stringWithFormat:@"KeyboardTextCell%@", [NSString stringWithFormat:@"%@", indexPath]];        [_cellDic setValue:identifier forKey:[NSString stringWithFormat:@"%@", indexPath]];        // 注冊Cell        [self.keyboardView registerClass:[KeyboardTextCell class]  forCellWithReuseIdentifier:identifier];  [objc] view%20plain copy print?派生到我的代碼片}                 KeyboardTextCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];                 cell.textLab.text = self.characterArr[indexPath.row];   return cell;  
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 石河子市| 额敏县| 都江堰市| 长岭县| 文安县| 全南县| 藁城市| 孟村| 临夏县| 大渡口区| 庆元县| 封丘县| 绩溪县| 门头沟区| 祥云县| 县级市| 舞钢市| 桦川县| 湾仔区| 深泽县| 长乐市| 景谷| 湟中县| 莱西市| 武强县| 含山县| 孟连| 弋阳县| 衡阳市| 从化市| 沂南县| 焦作市| 石河子市| 波密县| 南阳市| 黄龙县| 文安县| 紫阳县| 龙门县| 广饶县| 民丰县|