UICollectionView上的DecorationViews在每次插入时都会重复。

3
我正在尝试使用UICollectionView创建一个书架,与iBooks应用程序类似。它的工作很好,但是每当我通过调用insertItemsAtIndexPaths:将新项目插入视图时,该项目会被正确插入,但我的书架项(这些是DecorationViews,是UICollectionReusableView的子类)变得越来越暗,显然一遍又一遍地被涂上颜色。但是,如果在UICollectionView上调用reloadData,一切都会正确绘制。
这是我在派生的UICollectionViewFlowLayout类中所做的:
- (void)prepareLayout:计算DecorationViews的框架。 - (NSArray *)layoutAttributesForElementsInRect:为所有与矩形相交的书架添加UICollectionViewLayoutAttributes。 - (UICollectionViewLayoutAttributes*)layoutAttributesForItemAtIndexPath:将我的项目属性的zIndex调整为1。 - (UICollectionViewLayoutAttributes*)layoutAttributesForDecorationViewOfKind:atIndexPath:将我的书架属性的zIndex调整为0。
就是这样。我有什么遗漏吗?
1个回答

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

嗨,Ash 我遇到了同样的问题,不知道你在提交错误报告后有没有得到任何反馈? - Michael Miscampbell
抱歉,还没有。如果发生了,我会更新openradar的。 - Ash Furrow

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接