我有一个UICollectionViewController和我的自定义单元格,并在我的cellForRowAtIndexPath:方法我设置单元格基于indexPath.row。 但是我得到了错误的结果,这个单元格即使在第一个位置出现,如果你来回滚动,它会随机弹出。我如何解决这个问题?UICollectionViewController - 有时显示错误单元格,在快速滚动
下面是代码:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
DVGCollectionViewCell *cell;
cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
if (indexPath.row == 0)
{
cell.imageView.image = [UIImage imageNamed:@"something1.png"];
cell.buyLabel.text = @"170";
cell.textLabel.text = @"11.2011";
}
return cell;
}