在重写UICollectionViewFlowLayout的时候会有很多坑,比如:

Logging only once for UICollectionViewFlowLayout cache mismatched frame
UICollectionViewFlowLayout has cached frame mismatch for index path <NSIndexPath: 0xc000000000200016> {length = 2, path = 0 - 1} - cached value: {{85, 40}, {55, 30}}; expected value: {{89, 40}, {55, 30}}
This is likely occurring because the flow layout subclass RHCollectionViewFlowLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them

这个警告的大致原因是:返回的数组时,没有使用该数组的拷贝对象,而是直接使用了该数组。找了一圈资料,大部分是说需要进行深拷贝。
emmm...该方案是可行的,只是大部分找错了地方。

stackoverflow解决方案中找到了匹配的解决方法:
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath方法中
将:UICollectionViewLayoutAttributes * currentItemAttributes = [super layoutAttributesForItemAtIndexPath:indexPath];
改成:UICollectionViewLayoutAttributes * currentItemAttributes = [[super layoutAttributesForItemAtIndexPath:indexPath] copy];

stackoverflow解决方式

具体GitHub解决案例

重写UICollectionViewFlowLayout报cache mismatched frame警告的更多相关文章

  1. WaterfallFlowLayout瀑布流用重写UICollectionViewFlowLayout类实现

    最近调研瀑布流,在gitHub上下了个Demo发现它的所有视图都是用Main.storyboard拖的, 自己研究半天没研究明白; 然后就又找了一个Demo, 它的视图全是手打的, 但是实现的方法不太 ...

  2. webpack4.0报WARNING in configuration警告

    在进行webpack打包工作时,先进行如下步骤 1). 安装webpack:推荐全局命令  cnpm install webpack -g 查看webpack版本 webpack -v 2) . 此时 ...

  3. 【hive】在alter修改元数据的时候报错 mismatched input 'xxxxx' expecting KW_EXCHANGE

    目的:修改表某个字段属性 语句: 报错信息 错误原因: 在HiveQL中,alter命令不使用与create或select相同的语义 ; 具体来说,您不能使用“ALTER DATABASE.TABLE ...

  4. vue cli搭建的vue项目 不小心开了eslint 一直报黄色的警告

    报错必须处理,警告也忍不了,发现在bulid -webpack.base.config.js 里找到 const createLintingRule = () => ({ /*test: /\. ...

  5. 【转载】row cache lock

    转自:http://blog.itpub.net/26736162/viewspace-2139754/   定位的办法: --查询row cache lock等待 select event,p1   ...

  6. php报错: PHP Warning: PHP Startup: memcache: Unable to initialize module

    在mac上通过brew 安装php的memcache扩展(brew install php56-memcache)后运行 ~  php -mPHP Warning:  PHP Startup: mem ...

  7. C#中在比较自定义对象的时候要重写Equals方法

    using System;using System.Collections.Generic;using System.Text; namespace Equal{    using System; c ...

  8. C# 重写Equals

    public class PerformanceRank { public int Rank { get; set; } public string Eid { get; set; } public ...

  9. 取消 Vue 中格式编译警告

    使用VS Code在学习 Vue 的过程中,博主是在2.0之后开始学习的,在写项目的时候发现控制台经常会报一大堆的警告,都是关于格式的,有时候少空格,有时候多空格,不胜其烦,出现这个问题是因为在初始化 ...

随机推荐

  1. Mybatis学习第三天——输入输出映射以及动态SQL

    注意:以下传入数据与输出数据类型部分使用别名的方式,别名在SqlMapConfig.xml核心文件中配置 1.输入映射 1.1 传递简单数据类型 1.2 传递pojo中的类类型 1.3 传递Query ...

  2. CentOS7路由、端口和服务排障常用命令

    1. ip route   显示主机基本路由信息 ~]# ip route default via 172.25.0.254 dev eth0  proto static  metric 1024 1 ...

  3. Python 词频统计

    利用Python做一个词频统计 GitHub地址:FightingBob [Give me a star , thanks.] 词频统计 对纯英语的文本文件[Eg: 瓦尔登湖(英文版).txt]的英文 ...

  4. python----------闭包 、装饰器

    闭包: 就是内层函数对外层函数(非全局变量的)非全局变量的引用 def func(): name = '老人家' def func1(): print(name)#局部变量对全局变量的引用 因为并没有 ...

  5. 沉淀再出发:spring boot的理解

    沉淀再出发:spring boot的理解 一.前言 关于spring boot,我们肯定听过了很多遍了,其实最本质的东西就是COC(convention over configuration),将各种 ...

  6. 函数去抖(debounce)与 函数节流(throttle)

    以下场景往往由于事件频繁被触发,因而频繁执行DOM操作.资源加载等重行为,导致UI停顿甚至浏览器崩溃. 1. window对象的resize.scroll事件 2. 拖拽时的mousemove事件 3 ...

  7. 匹配IP的正则表达式

    正则表达式匹配IP 1 ((25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)\.){3}(25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|[1-9])  

  8. linux mint sublime3的c编译环境配置

    通过Tools>>Build System>>New Build System弹出新建文件来设置,也可以replace覆盖以前的 一种方式,konsole可以通过sudo ap ...

  9. HTML的CoreText流畅度超过WebView。CoreText第三方框架DTCoreText的介绍

    为什么要用CoreText(富文本)来取代WebView去显示内容.主要的原因就WebView有很大的问题,性能,FPS,卡顿,与原生不搭.这些都是大问题. WebView的缺点 1.直接使用WebV ...

  10. HTML 5中的文件处理之FileAPI

    在众多HTML5规范中,有一部分规范是跟文件处理有关的,在早期的浏览器技术中,处理小量字符串是js最擅 长的处理之一.但文件处理,尤其是二进制文件处理,一直是个空白.在一些情况下,我们不得不通过Fla ...