[英]iOS: mark UICollectionView' cell as displayed
我正在与UICollectionViewCell一起显示事件列表。
在屏幕上进行比较时,如何将每个单元格标记(永久)为“已读”?
如果仅向下滚动,则可以执行此操作,如果我“滚动”“播放”(上下移动),请停止工作标记为已读取的“随机”单元格:我认为是由单元格的重用引起的。 那么,我该如何解决呢?
细节:
每个单元都是定制的笔尖
NSString* cellName = [[MyCell class] description];
UINib* nib = [UINib nibWithNibName:cellName bundle:[NSBundle mainBundle]];
[self.collectionView registerNib:nib forCellWithReuseIdentifier:name];
并在cellForItemAtIndexPath委托中:
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
NSString* name = [[MyCell class] description];
QVEventWallPostCell *cell = [cv dequeueReusableCellWithReuseIdentifier:name forIndexPath:indexPath];
if(/* control */) {
[cell markAsRead];
} else {
/* */
}
...
}
将isRead布尔值属性添加到用于在每个单元格而不是单元格中显示数据的Event对象中,并在下次显示该单元格时检查其值
Event* thisEvent= [self.dataSource objectAtIndex:indexPath.item];
if(!thisEvent.isRead) {
thisEvent.isRead=YES;
// whatever function you use to show the cell as unread; in case the cell is reused from a read cell
}
else {
// whatever function you use to show the cell as read
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.