UICollectionView滚动的时候会出现cell消失的情况

RT,具体情况是:滚下去的时候发现最后一排不显示了,再滚上来,第一排的cell也不显示了。

但是不论是消失的第一排还是最后一排,都可以触发didSelectItemAtIndexPath

参考了如下提问:
http://stackoverflow.com/questions/13360975/uicollectionviews-cell-disappearing-ios
http://stackoverflow.com/questions/15310824/uicollectionview-cell-disappears

看来stackoverflow上也没能很好的解决这个问题。
如果没有work around的话就只好试试PSTCollectionView了。

环境:XCode 5.1,编译目标iOS 7.1


@未解 的提醒,将相关代码贴上:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    AppInMineCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AppInMineCell" forIndexPath:indexPath];
    App *app = [self.myapps objectAtIndex:indexPath.row];

    NSURL *url = [NSURL URLWithString:[app.iconURL stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];

    cell.appName.text = app.name;
    //appIcon是一个继承了UIImageView的AsyncImageView,可自行pod search
    cell.appIcon.imageURL = url;

    // circular app icon so Apple won't say we copy
    cell.appIcon.layer.masksToBounds = YES;
    cell.appIcon.layer.cornerRadius = 32.0f;

    return cell;
}

UPDATE:

发现并不是只要往上滑下面的cell就会消失,scroll滚动的程度要大到触发了bounce,才会出现cell消失的情况。

temperory fix: 禁用bounce

阅读 20.1k
4 个回答

看样子UICollectionView还是有bug的! 你贴的链接里有人说解决了这个问题:“Rob's tip about the bug helped me. The bug states that if the section insets and cells widths and spacing add up exactly to the width of the screen then the first column sometimes randomly dissappears and reappears for some cells in some places. Rather than subclass or change the cell widths, I changed the section insets for left and right in my storyboard from 6 to 4 and it I haven't seen the problem again.”, 你有试过这个方法吗?

新手上路,请多包涵
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏