【发布时间】:2012-11-17 14:14:03
【问题描述】:
请帮助我,如何保存UICollectionViewCell 的状态。例如:我有带有UIWebView 的单元格,当我dequeueReusableCellWithReuseIdentifier:forIndexPath: 返回错误的单元格时,不是这个indexPath 和之后UIWebView 内容将重新加载正确的indexPath 抽搐。谢谢!
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
NewsCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NEWS_CELL" forIndexPath:indexPath];
if (!cell.isShowed) { // I just added boolean property
cell.isShowed = YES;
/*** some init actions ***/
}
return cell;
}
如果我使用这种方法,带有cell.isShowed == YES 的单元格会返回错误的indexPath。但是如果我不使用cell.isShowed UIWebView 的内容将在每个显示单元格中重新加载
对不起我的英语:)
【问题讨论】:
-
你使用了正确的 indexPath 吗?
-
是的,我只使用 indexPath 从 - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
-
“不适合这个 indexPath”是什么意思?你能粘贴你的代码吗?我需要更多代码来看看你有什么问题。
-
"return on wrong indexPath" 表示单元格显示成功但行错了?
-
那么,sunkehappy,您对此有什么想法吗? :)
标签: objective-c ios uiwebview uicollectionview uicollectionviewcell