在重写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. 2 pygraphviz在windows10 64位下的安装问题(反斜杠的血案)

    可以负责任的说,这篇文档是windows10安装pygraphviz中,在中文技术网站中最新的文档,没有之一.是自己完全结合各种问题,包括调试等,总结出来的. 问题来源:主要是可视化RvNN网络的树结 ...

  2. Spring中的转换器:Converter

    配置spring的配置文件: <bean id="conversionService" class="org.springframework.context.sup ...

  3. 网络虚拟化技术 -- LXC TUN/TAP MACVLAN MACVTAP

    Linux的网络虚拟化是LXC项目中的一个子项目,LXC包括文件系统虚拟化,进程空间虚拟化,用户虚拟化,网络虚拟化,等等 [ LXC内核命名空间 ],这里使用LXC的网络虚拟化来模拟多个网络环境. 创 ...

  4. 用java实现从命令行接收多个数字,求和之后输出结果。

    用java实现从命令行接收多个数字,求和之后输出结果. 1 设计思想: (1)建立类. (2)输出参数个数. (3)定义int型的num和sum,分别用来存储参数和参数的和. (4)用for循环讲参数 ...

  5. androidcookie存储sqllite

    /**声明一些数据库操作的常量*/  private static SQLiteDatabase mDatabase = null;  private static final String DATA ...

  6. SVN global ignore pattern

    *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store */bin */ ...

  7. setfacl 命令的常用用法

    setfacl命令----可以用来细分linux下的文件权限. chmod命令----可以把文件权限分为u,g,o三个组,而setfacl可以对每一个文件或目录设置更精确的文件权限. 换句话说,set ...

  8. System.Buffer 以字节数组(Byte[])操作基元类型数据

    1. Buffer.ByteLength:计算基元类型数组累计有多少字节组成. 该方法结果等于"基元类型字节长度 * 数组长度" , , }; , , }; , , }; Cons ...

  9. codeforces 12D Ball

    codeforces 12D Ball 这道题有两种做法 一种用树状数组/线段树维护区间最值,一种用map维护折线,昨天我刚遇见了一道类似的用STL维护折线的题目: 392D Three Arrays ...

  10. iOS开发中的Markdown渲染

    iOS开发中的Markdown渲染 BearyChat的消息是全面支持Markdown语法的,所以在开发BearyChat的iOS客户端的时候需要处理Markdown的渲染. 主要是两套实现方案: 直 ...