我想顯示一個UICollectionView,其中每行包含2行和100個單元格。爲UICollectionView指定行號和列號
// 1
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {
return 100;
}
// 2
- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView {
return 2;
}
// 3
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MyCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
cell.lbl.text = @"Data";
return cell;
}
我得到這個:
我如何可以指定一個行號爲UICollectionView?我想創建一個2x100表格。
非常感謝您... – onivi
看起來不正確 – aelam
使用自定義佈局更好:http://stackoverflow.com/a/35362818/833885 – brianLikeApple