当前位置: 首页 > 面试题库 >

警告:UICollectionViewFlowLayout已为索引路径“ abc”缓存帧不匹配

翟光赫
2023-03-14
问题内容

这是引起警告的代码:

private override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? {
    let attributes = super.layoutAttributesForItemAtIndexPath(indexPath)
    let distance = CGRectGetMidX(attributes!.frame) - self.midX;
    var transform = CATransform3DIdentity;
    transform = CATransform3DTranslate(transform, -distance, 0, -self.width);
    attributes!.transform3D = CATransform3DIdentity;
    return attributes
}

控制台还会打印:

这很可能发生,因为流布局“ xyz”正在修改UICollectionViewFlowLayout返回的属性而不复制它们。

如何解决此警告?


问题答案:

这很可能发生,因为流布局“ xyz”正在修改UICollectionViewFlowLayout返回的属性而不复制它们

确实,这就是您正在做的事情:

private override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes? {
    let attributes = super.layoutAttributesForItemAtIndexPath(indexPath)
    let distance = CGRectGetMidX(attributes!.frame) - self.midX;
    var transform = CATransform3DIdentity;
    transform = CATransform3DTranslate(transform, -distance, 0, -self.width);
    attributes!.transform3D = CATransform3DIdentity;
    return attributes
}

我希望您能简单地说:

let attributes = 
    super.layoutAttributesForItemAtIndexPath(indexPath).copy() 
    as! UICollectionViewLayoutAttributes

或类似的问题将消失。



 类似资料:
  • 这是导致警告的代码: 控制台还打印: 这可能是因为流布局“xyz”正在修改UICollectionViewFlowLayout返回的属性,而没有复制它们。 如何修复此警告?

  • 问题内容: 缓存解决方案和索引解决方案之间的真正区别是什么?在我看来,索引解决方案实际上是具有运行搜索查询功能(例如:Elastic Search)的缓存。是否有任何真正的理由在同一项目中同时使用缓存解决方案和索引解决方案,或者索引解决方案基本上会使其他任何缓存变得多余? 示例:假设我对ElasticSearch使用NEST,它将存储并返回POCO;如果我随后查询ElasticSearch并已将P

  • 问题内容: 我最近安装了Jasperserver和JaspersoftStudio以与JasperReports一起使用。在创建到PostgreSQL数据库的数据库连接并从该数据库生成报告之后,我在JaspersoftStudio中收到以下警告,但我无法解决。 我发现该配置没有关联的JRE系统库,所以我尝试使用Jaspersoft Studio附带的JRE系统库[JavaSE-1.6],但无法解决

  • 我试图捕捉包含指定路径的路径,如path/to/my/url/variablePart,在管道条件中,我放入了ctx.url.path == 'path/to/my/url/',但不幸的是,它只获取包含path/to/my/url/的日志,而不考虑包含可变部分的其他日志,有一个通配符可以帮助我捕捉以' path/to/my/url/'开头的每个路径。?我已经试过做CTX . URL . path

  • 问题内容: 我想为查询建立索引 如果我有一个像下面这样的表 我想创建一个索引,以便能够高效地执行以下操作: 还有这个: 我也希望该表能够实时更新。 如何创建这样的索引?(我有一种需要索引的感觉,但是我对需要给它提供什么选择感到困惑) 我正在使用Oracle 10g。 问题答案: 我会用这个(将您的最小和最大长度设置为适当值) 这些参数在此处解释《Oracle文本参考》

  • 在ubuntu上使用Libreoffice转换文件时出错: CompletedProcess(args=['soffice'、'--headless'、'--convert to'、'txt:Text'、'/var/www/Project/temp/e4bac2c2e7c04eb79cfa522967a30dd3.docx'、'--outdir'、'/var/www/Project/temp/']