Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.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 UIcollectionViewCells在更改其布局属性时表现异常_Ios_Uicollectionview_Uicollectionviewcell_Uicollectionviewlayout - Fatal编程技术网

Ios UIcollectionViewCells在更改其布局属性时表现异常

Ios UIcollectionViewCells在更改其布局属性时表现异常,ios,uicollectionview,uicollectionviewcell,uicollectionviewlayout,Ios,Uicollectionview,Uicollectionviewcell,Uicollectionviewlayout,我想查看像safari最近的标签 我可以在一定程度上创造,但如果细胞数量增加,它看起来像 而且,当我选择任何单元格时,它也不会返回正确的索引路径 这是我使用的代码 -(UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath { NSInteger index = indexPath.row; NSInteger total = [self.coll

我想查看像safari最近的标签

我可以在一定程度上创造,但如果细胞数量增加,它看起来像

而且,当我选择任何单元格时,它也不会返回正确的索引路径

这是我使用的代码

-(UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
 {

  NSInteger index = indexPath.row;
  NSInteger total = [self.collectionView numberOfItemsInSection:0];



UICollectionViewLayoutAttributes* attr = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath];



attr.frame = CGRectMake(10, 0, self.collectionView.frame.size.width - 20, 350);

CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0/-500;

if (indexPath.row+1 == total)
{
    transform = CATransform3DTranslate(transform, 0, (CARD_SPACING * index), 15);
    attr.transform3D = CATransform3DRotate(transform, 0, 0, 0, 0);
}
else
{
    transform = CATransform3DTranslate(transform, 0, (CARD_SPACING * index), 0);
    attr.transform3D = CATransform3DRotate(transform, -(M_PI*18)/180, 1, 0, 0);
}


return attr;
}
这只是一个粗略的代码。我走对了还是错了,谁能帮我一下吗。因为我第一次创建自定义布局

如果这个完整的代码不正确,请告诉我合适的方法来实现它

这段代码对3或4个单元格运行良好,但随着我增加单元格数量,它看起来很奇怪