UICollectionViewFlowLayout has cached frame mismatch for index path
2015-10-25 11:07
344 查看
在升级XCode7.0使用UICollectionViewLayout进行自定义布局时,调试台会出现以下的警告打印。
UICollectionViewFlowLayout has cached frame mismatch for index path {length = 2, path = 0 - 0} - cached value: {{122, 15}, {170, 170}}; expected value: {{157, 50}, {100, 100}}
This is likely occurring because the flow layout subclass LineLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them
这个警告来源主要是在使用layoutAttributesForElementsInRect:方法返回的数组时,没有使用该数组的拷贝对象,而是直接使用了该数组。解决办法对该数组进行拷贝,并且是深拷贝。拷贝代码如下:
将layoutAttributesForElementsInRect:方法返回的数组扔到这个方法中,并且使用返回后的数组就行了。
UICollectionViewFlowLayout has cached frame mismatch for index path {length = 2, path = 0 - 0} - cached value: {{122, 15}, {170, 170}}; expected value: {{157, 50}, {100, 100}}
This is likely occurring because the flow layout subclass LineLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them
这个警告来源主要是在使用layoutAttributesForElementsInRect:方法返回的数组时,没有使用该数组的拷贝对象,而是直接使用了该数组。解决办法对该数组进行拷贝,并且是深拷贝。拷贝代码如下:
- (NSArray *)deepCopyWithArray:(NSArray *)array { NSMutableArray *copys = [NSMutableArray arrayWithCapacity:array.count]; for (UICollectionViewLayoutAttributes *attris in array) { [copys addObject:[attris copy]]; } return copys; }
将layoutAttributesForElementsInRect:方法返回的数组扔到这个方法中,并且使用返回后的数组就行了。
相关文章推荐
- 安卓模拟器"bluestacks"在电脑上的设置.(宽,高)
- 【UER #4】被粉碎的数字
- 鸟哥的私房菜上 xpenguins 设备(ubuntu 12.04)
- 【UER #4】被删除的黑白树
- Get Current LOV Query SQL
- UI 炫技要不得!设计师别求花俏,简单明了才最重要
- HDU 1242 Rescue (BFS+优先队列)
- Gradle Plugin Samples 之 Gradle Build Variants(六)
- Gradle Build Configs
- BZOJ 4302 Buildings 解题报告
- BZOJ 4302 Buildings 解题报告
- Hadoop应用-------Hadoop计算能力调度器(Capacity Scheduler)应用和配置{hadoop mradmin -refreshQueues动态更新队列和容量}其他调度器比较
- Learn from Synchronized and BlockingQueue
- Leetcode: Unique Paths
- UE4蓝图案例:制作透明黑色玻璃
- Queue
- POJ 1458 Common Subsequence
- POJ 1458 Common Subsequence
- Android:带你玩转Servie,子线程,与UI线程通信[导入导出]
- cf 11a Increasing Sequence