Reputation: 8942
I have a collection view,in which i have a cell.On story board height of cell is equal to the height of collection view.But when i run it shows me the bottom space.Please tell me how can i remove that.I have used following code to remove this.
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
[self setAutomaticallyAdjustsScrollViewInsets:NO];
// return UIEdgeInsetsMake(0,8,0,8); // top, left, bottom, right
if (collectionView==self.album_collection_view)
{
return UIEdgeInsetsMake(0,10,0,10);
}// top, left, bottom, right
else
return UIEdgeInsetsMake(0,10,0,10);
}
Please tell how to remove it?
Upvotes: 2
Views: 1373
Reputation: 47
I am assuming that there is only one row of cells. If so you can try to set the cell height in collectionView:cellForItemAtIndexPath:.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
...
CGRect newFrame = cell.frame;
newFrame.size.height = CGRectGetHeight(collectionView.frame);
cell.frame = newFrame;
return cell;
}
Upvotes: 0