我正在嘗試將我的UICollectionView
排除,使其成爲每頁2x3網格。以下是我迄今爲止得到:鋪設UICollectionView以創建2x3網格的問題iOS
正如你所看到的,接下來的「頁」是從權,我不想偷窺。我想如果我知道我的寬度始終是320pts(僅限於iPhone
),那麼我希望我的細胞在width
之間變爲130pts,兩邊都是15pts。
代碼佈局delegate
:
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout*)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(130, 130);
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout*)collectionViewLayout
insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(20.0f, 15.0f, 20.0f, 15.0f);
}
而且還cellForItemAtIndexPath:
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath{
CustCollectionViewCell *cell =
[collectionView dequeueReusableCellWithReuseIdentifier:kReuseID
forIndexPath:indexPath];
//Set up list name label
cell.LblListName.font = [self getDefaultFontWithSize:15.0f];
cell.LblListName.textColor = fontAndTertiaryColor;
cell.LblListName.textAlignment = NSTextAlignmentCenter;
cell.LblListName.text = @"Failtron";
//cell.LblListName.adjustsFontSizeToFitWidth = YES;
cell.backgroundColor = secondaryColor;
cell.parallaxIntensity = kParallaxMotion;
[Utilities createViewBorder:cell];
return cell;
}
我想到了一個插圖將在CSS
像padding
,但我相信我跟那個一個標誌,我還應該注意到,在UIStoryboard
我的佈局設置爲流動。請讓我知道,如果我錯過了任何相關的代碼,這是我第一次嘗試UICollectionView
。我想這也是scroll
horizontally
。
所以你希望collectionview水平滾動,但你不想看到下一頁。是對的嗎? – jhilgert00
是的,先生,這是正確的 –