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

这是导致警告的代码:

私有覆盖函数布局属性ForItemAtIndexPath(indexPath:NSIndexPath)->UICollectionViewLayoutAttribute?{
让attributes=super.layouttributesforItemAtIndexPath(indexPath)
让距离=CGRectGetMidX(attributes!.frame)-self.midX;
var transform=CATTransferM3DidEntity;
变换=CATTransferM3DTTranslate(变换,-距离,0,-自身宽度);
属性!.transform3D=CATTransformM3DidEntity;
返回属性
}

控制台还打印:

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

如何修复此警告

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

果不其然,这正是你正在做的:

私有覆盖函数布局属性ForItemAtIndexPath(indexPath:NSIndexPath)->UICollectionViewLayoutAttribute?{
让attributes=super.layouttributesforItemAtIndexPath(indexPath)
让距离=CGRectGetMidX(attributes!.frame)-self.midX;
var transform=CATTransferM3DidEntity;
变换=CATTransferM3DTTranslate(变换,-距离,0,-自身宽度);
属性!.transform3D=CATTransformM3DidEntity;
返回属性
}

我想如果你只是说:

让属性=
super.layouttributesforItemAtIndexPath(indexPath).copy()
像UICollectionViewLayoutAttribute

或者类似的,问题就会消失

发表评论