【问题标题】:DecorationViews on UICollectionView are duplicated on every insertUICollectionView 上的装饰视图在每次插入时都会重复
【发布时间】:2013-02-14 19:48:59
【问题描述】:

我正在尝试使用 UICollectionView 创建一个书架,这与 iBooks 应用程序不同。

它工作得很好,但是每当我将一个新项目插入到视图中(通过调用insertItemsAtIndexPaths:),该项目被正确插入,但我的货架项目(它们是装饰视图,@ 的子类987654322@) 越来越黑,显然是被一遍又一遍地画了。 但是,如果在 UICollectionView 上调用 reloadData,则一切都正确。

这是我在派生的UICollectionViewFlowLayout 类中所做的:

  • - (void)prepareLayout 计算帧数 装饰视图

  • - (NSArray *)layoutAttributesForElementsInRect: Adding UICollectionViewLayoutAttributes 用于与 正确

  • - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *) 将我的项目属性的 zIndex 调整为 1

  • - (UICollectionViewLayoutAttributes *)layoutAttributesForDecorationViewOfKind:(NSString *) atIndexPath:(NSIndexPath *) 为我的书架调整 zIndex 属性为 0

就是这样。 我错过了什么吗?

【问题讨论】:

    标签: ios uicollectionview


    【解决方案1】:

    听起来像是装饰视图的(另一个)错误。我已经提交了bug,当设备旋转时它们会被复制。

    【讨论】:

    • 嗨,Ash,我遇到了同样的问题,不认为您对提交的错误有任何反馈吗?
    • 恐怕还没有。如果发生这种情况,我会更新 openradar。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-27
    • 1970-01-01
    • 1970-01-01
    • 2021-08-26
    • 1970-01-01
    • 2016-01-13
    • 1970-01-01
    相关资源
    最近更新 更多