如何將UICollectionViewCell
限制爲10或20?如果UICollectionViewCell
從API加載太多的單元格。如何限制UICollectionViewCell
-(NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
-(NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.items.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
eventisi* list = [_items objectAtIndex:indexPath.row];
UIImageView *iconEvent = (UIImageView*)[cell viewWithTag:1];
NSURL *url = [NSURL URLWithString:list.EVENT_IMAGE];
[iconEvent setImageWithURL:url usingActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
iconEvent.clipsToBounds = YES;
// Configure the cell
UILabel *judul = (UILabel *)[cell viewWithTag:2];
judul.text = list.EVENT_NAME;
judul.numberOfLines =2;
judul.lineBreakMode = NSLineBreakByWordWrapping;
judul.font = [UIFont systemFontOfSize:10];
return cell;
}
也許你可以返回'numberOfItemsInSection'較少的項目。 – rmaddy