Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UICollectionViewLayoutAttribute在看似相同的属性上出现不一致错误_Ios_Uicollectionview_Uicollectionviewlayout - Fatal编程技术网

Ios UICollectionViewLayoutAttribute在看似相同的属性上出现不一致错误

Ios UICollectionViewLayoutAttribute在看似相同的属性上出现不一致错误,ios,uicollectionview,uicollectionviewlayout,Ios,Uicollectionview,Uicollectionviewlayout,由于UICollectionViewLayoutAttribute不匹配,我的自定义collectionViewLayout上很少出现“NSInternalInconsistencyException”错误,但据我所知,这些属性应该相等。苹果是否希望我们缓存所有这些属性并返回完全相同的属性 下面是两个正在讨论的布局属性。正如您所看到的,除了实际内存地址之外,它们是相同的 <UICollectionViewLayoutAttributes: 0x1703e1f00> index pat

由于UICollectionViewLayoutAttribute不匹配,我的自定义collectionViewLayout上很少出现“NSInternalInconsistencyException”错误,但据我所知,这些属性应该相等。苹果是否希望我们缓存所有这些属性并返回完全相同的属性

下面是两个正在讨论的布局属性。正如您所看到的,除了实际内存地址之外,它们是相同的

<UICollectionViewLayoutAttributes: 0x1703e1f00> index path: (<NSIndexPath: 0xc00000000000000e> {length = 1, path = 0}); element kind: (DRSupplementaryViewKind); frame = (22 0; 61 25); alpha = nan; zIndex = 402;

<UICollectionViewLayoutAttributes: 0x1703e3600> index path: (<NSIndexPath: 0xc00000000000000e> {length = 1, path = 0}); element kind: (DRSupplementaryViewKind); frame = (22 0; 61 25); alpha = nan; zIndex = 402;
索引路径:({length=1,path=0});元素种类:(DRSupplementaryViewKind);帧=(22 0;61 25);α=nan;zIndex=402;
索引路径:({length=1,path=0});元素种类:(DRSupplementaryViewKind);帧=(22 0;61 25);α=nan;zIndex=402;

这里有一个有趣的事实,“NaN==NaN”的结果是什么?没错,这是假的。因此,即使在两个布局属性上调用了isEquals,即使它们看起来相同,isEquals还是返回false,因为“没有任何东西等于Nan——甚至Nan本身都不等于!!!”

这意味着,如果其中一个浮点属性为NaN,则[myLayoutAttribute isEqual:[myLayoutAttribute copy]]为false。是的

我希望这能帮别人省去我一直以来所面临的痛苦