Ios 集合视图并排添加自定义单元格

Ios 集合视图并排添加自定义单元格,ios,collectionview,Ios,Collectionview,我想添加集合视图,如 我该怎么办? 我已经做了。这是我的代码 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { if (section == 0) { return 1; } if (section == 1) { return 4; }

我想添加集合视图,如

我该怎么办?
我已经做了。这是我的代码

   - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    if (section == 0)
    {
        return 1;
    }
    if (section == 1)
    {
        return 4;
    }
    return 0;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView;
{
    return 2;
}
- (void)_configureCell:(CustomCollectionViewCell *)cell forIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
    {
        cell.imgview.image = [UIImage imageNamed:@"Login-01.png"];
        cell.lblTitle.text = @"Jack";
    }
    else if (indexPath.section == 1)
    {
        if (indexPath.row == 0)
        {
            cell.imgview.image = [UIImage imageNamed:@"Profile-01.png"];
            cell.lblTitle.text = @"PROFILE";
        }
        else if (indexPath.row == 1)
        {
            cell.imgview.image = [UIImage imageNamed:@"My-order-01.png"];
            cell.lblTitle.text = @"MY ORDER";
        }
        else if (indexPath.row == 2)
        {
            cell.imgview.image = [UIImage imageNamed:@"Wishlist.png"];
            cell.lblTitle.text = @"WHISHLIST";
        }
        else if (indexPath.row == 3)
        {
            cell.imgview.image = [UIImage imageNamed:@"Settings-01.png"];
            cell.lblTitle.text = @"SETTINGS";
        }
    }
}
- (UIEdgeInsets)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(1, 1, 1, 1); // top, left, bottom, right
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
    return 1.0;
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    return 1.0;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CustomCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CustomCell" forIndexPath:indexPath];

    [self _configureCell:cell forIndexPath:indexPath];

    return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
    {
            return  CGSizeMake(self.CollectionView.frame.size.width, (self.CollectionView.frame.size.height / 2) - 20);
//        return CGSizeMake(414, 100);
    }
    else
    {
            return  CGSizeMake((self.CollectionView.frame.size.width / 2) - 40, ((self.CollectionView.frame.size.height / 2) / 2) - 40);
//        return CGSizeMake(211, 181);
    }
}

我必须在其中添加自定义单元格。我不能理解流程布局

请帮帮我。谢谢。

一旦你有了想法,只要更改
NSInteger numberOfColumns=2一旦你有了这个想法,只需更改
NSInteger numberOfColumns=2