iOS - UICollectionView spacing still there when set to 0 - How to set with no spacing between cells

前端 未结 6 1428
南旧
南旧 2020-12-16 12:03

I have a simple UICollectionView which I have set with 0 spacing in InterfaceBuilder but when I populate the collection view with cells there is still some spacing. Is there

6条回答
  •  萌比男神i
    2020-12-16 12:38

    Simple solution for your Query. Add this in your viewController's .m file:

    -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
    {
        ProductDetailViewController *HomeVC = [self.storyboard instantiateViewControllerWithIdentifier:@"ProductDetailView"];
        HomeVC.title = @"DemoProject";
        [self.navigationController pushViewController:HomeVC animated:YES];
    }
    
    - (UIEdgeInsets)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
        return UIEdgeInsetsMake(0, 0, 0, 0); // top, left, bottom, right
    }
    
    - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    
        return 0.0;
    }
    
    - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
        return 0.0;
    }
    

提交回复
热议问题