Ios UICollectionViewCell之间不需要的空间

Ios UICollectionViewCell之间不需要的空间,ios,uicollectionview,uicollectionviewcell,uicollectionviewlayout,Ios,Uicollectionview,Uicollectionviewcell,Uicollectionviewlayout,我有一个UICollectionView,还有一个自定义的UICollectionTableViewCell,里面有一个UIImageView 我得到的间距如下: #pragma mark - UICollectionViewDelegate - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { // TODO: Selec

我有一个UICollectionView,还有一个自定义的UICollectionTableViewCell,里面有一个UIImageView

我得到的间距如下:

#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    // TODO: Select Item
}
- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
    // TODO: Deselect item
}




#pragma mark – UICollectionViewDelegateFlowLayout

- (UICollectionViewFlowLayout *)collectionViewFlowLayout
{
    UICollectionViewFlowLayout *flowLayout = [UICollectionViewFlowLayout new];
    flowLayout.sectionInset = UIEdgeInsetsZero;
    flowLayout.minimumInteritemSpacing = 0.0f;
    flowLayout.minimumLineSpacing = 0.0f;
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    return flowLayout;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    CGFloat widthOfTheScreen =self.view.frame.size.width;
    CGSize retval = CGSizeMake(widthOfTheScreen , widthOfTheScreen *1.5);
    return retval;
}

- (UIEdgeInsets)collectionView:
(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsZero;
}
现在,当我运行它时,它完全符合我的目的。它在视图的中心显示图像(我的collectionview在一个标签下),它几乎完全按照我的要求显示图像(不要担心底部空间不足)

下图显示了第一项(无滚动):

然而,当我向右滚动时,我开始得到轻微的间隙。而且,每滚动一次,间隔就会变大(我的背景是红色的,所以你可以看到)

这是第一卷:

这是第二卷:

这是第三卷:

模式也是如此。我有一种感觉,这与插图有关,但不知道如何删除它

或者这与某个开端有关?我从未听说过这样的事,但这也可能是个问题


事先非常感谢您的建议。

您的UI感觉和外观都非常奇怪。我当然希望imageview不会嵌套在collection视图中的另一个scrollview中。如果你愿意把这个项目付诸实施,我们可以运行它,看看问题是什么

谢谢你的回答。不,我在视图控制器中使用了collectionview。没有使用滚动视图。我一到家就把github的代表地址发出去。