2015-04-22 2 views
0

Ниже мой код. Я могу загрузить, но некоторое пространство между двумя ячейками. Как избежать.Как настроить ячейку просмотра коллекции в соответствии с изображениями

- (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; 
} 

ответ

0

Возможно, вам нужно избегать вставок.

Надень: return UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0);

Вместо: return UIEdgeInsetsMake(5.0, 5.0, 5.0, 5.0);

Смежные вопросы