在重写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. QTableview 获取鼠标坐标的item(QModelIndex)

    要实现的功能是QTableview中Item项上右键弹出菜单这就必然要判断点击右键时鼠标指针是否在QTableView的Item上 如果是QTableWidget可以用itemAt来判断QTableV ...

  2. jekyll开发静态网站

    一.Ruby环境安装配置 首先下载ruby安装ruby download ,安装完ruby后,再安装rubyGems:运行gem update --system即可. 然后下载DevKit-mingw ...

  3. linux_day3

    1.grep与find的区别? grep是查找文件内的字符而find则是查找文件 2.显示/etc/passwd中以nologin结尾的行 3. 输入ip addr命令后,过滤出包含ip的行 ip a ...

  4. 毕向东_Java基础视频教程第20天_IO流(5~6)

    第20天-05-IO流(文件列表一) static File[] listRoots() List the available filesystem roots. String[] list() Re ...

  5. innerHTML,innerText,textContent,outerHTML的用法以及区别

    innerHTML获取的是对象起始的位置到终止位置全部内容,包含html标签. innerText和textContent结果是一样的,不包含标签,直接获取标签内的内容,区别是两者浏览器的兼容性. o ...

  6. 沉淀,再出发:PHP的简单使用

    沉淀,再出发:PHP的简单使用 一.前言 关于PHP,笔者在本科的时候就听到了太多太多,可惜虽然看了很多的教材,听到了无数遍,也没有系统性的整理过和学习过这方面的知识,这点无论什么时候想起来都是一种遗 ...

  7. 原生ajax和jsonp

    封装方法: function ajax(options) { options = options || {}; options.type = (options.type || "GET&qu ...

  8. [COGS 2064]爬山

    2064. 爬山 ★☆   输入文件:mountain.in   输出文件:mountain.out   简单对比时间限制:1 s   内存限制:256 MB [题目描述] 球有一天走在街上. 一个健 ...

  9. Angular2 Pipe

    AngularJs 1.x 中使用filters来帮助我们转换templates中的输出,但在Angular2中使用的是pipes,以下展示Angular 1.x and Angular 2中filt ...

  10. JS实现图片上传之前先预览

    <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat=&quo ...