【问题标题】:UICollectionView design flow layout for attached image附加图像的 UICollectionView 设计流程布局
【发布时间】:2015-05-15 11:19:55
【问题描述】:

我附上了我所做的和我必须实现的目标。请指导我实现这一目标。

我已经做到了:

我想实现以下目标:

这是我的代码:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    CGSize size; 
    if (indexPath.row == DIGIT_INT_2 || indexPath.row == DIGIT_INT_6 || indexPath.row == DIGIT_INT_7)
        size = CGSizeMake(150, 68); 
    else if (indexPath.row == DIGIT_INT_3 || indexPath.row == 13)
        size = CGSizeMake(150, 150);
    else
        size = CGSizeMake(68, 68);
    return size;
}

【问题讨论】:

  • 请分享您代码的相关部分,否则很难提供帮助。
  • @WaiHaLee 感谢先生的回复直到现在我添加了 uicollectionview 并添加了使用流布局委托方法定义的项目大小:-- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout * )collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {CGSize size; if (indexPath.row == DIGIT_INT_2 ||indexPath.row == DIGIT_INT_6 || indexPath.row == DIGIT_INT_7) {size = CGSizeMake(150, 68); }else if (indexPath.row == DIGIT_INT_3 ||indexPath.row == 13) {size = CGSizeMake(150, 150);}elsesize = CGSizeMake(68, 68);返回大小;}
  • 我的意思是 edit 你的问题包括代码。这样,您就可以对代码进行格式化,使其更易于阅读。
  • 你看过RFQuiltLayout吗?
  • 感谢 Azat 的回复,我通过我的方式解决了。

标签: ios xcode uicollectionview uicollectionviewlayout


【解决方案1】:

我找到了答案,我通过自定义 UICollectionViewFlowLayout 类并继承方法- (NSArray *) layoutAttributesForElementsInRect:(CGRect)rect 并使用前一个项目框架和当前项目框架来实现。

但在此之后出现了一个新问题,一个项目在滚动后消失了。我没能找到为什么会发生这种情况。经过两天的工作,我必须采取另一种方式来实现这一目标。 感谢 Wai Ha Lee 格式化问题。

现在我的消失问题被这个问题解决了:- UICollectionView's cell disappearing

【讨论】:

    猜你喜欢
    • 2016-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-03
    相关资源
    最近更新 更多