如何根据图像

时间:2015-04-22 13:31:21

标签: ios objective-c iphone uicollectionview

下面是我的代码。我能够加载两个单元格之间的空间。如何避免。

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return [dashBoard_img count];
}
- (CGSize)collectionView:(UICollectionView *)collectionView
                  layout:(UICollectionViewLayout *)collectionViewLayout
  sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UIImage * image = [UIImage imageNamed:[dashBoard_img objectAtIndex:indexPath.row]];
    return image.size;
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return UIEdgeInsetsMake(5.0, 5.0, 5.0, 5.0);
}

- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewFlowLayout *)collectionViewLayout
interitemSpacingForSectionAtIndex:(NSInteger)section {
    return 2.0;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    FMMosaicCellView *cell = [collectionView dequeueReusableCellWithReuseIdentifier:[FMMosaicCellView reuseIdentifier] forIndexPath:indexPath];
   // float horizontal = 8.0;
    //float vertical = 15.0;
    UIImage *image = [UIImage imageNamed:[dashBoard_img objectAtIndex:indexPath.row]];
    cell.imageView.frame = CGRectMake(cell.imageView.frame.origin.x, cell.imageView.frame.origin.y, image.size.width, image.size.height);
//    cell.imageView.frame = CGRectMake(horizontal, cell.imageView.frame.origin.y, image.size.width, image.size.height);
    cell.imageView.image = image;
    return cell;
}

2 个答案:

答案 0 :(得分:0)

也许你必须避免插入。

把这个:return UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0);

而不是:return UIEdgeInsetsMake(5.0, 5.0, 5.0, 5.0);

答案 1 :(得分:0)