サブクラス化されたCollectionViewCelliには、UILabelのみが含まれています。グリッドを取得するには、CGRectInsetを含むUILabelをセルに追加します。
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor orangeColor];
self.label = [[UILabel alloc] initWithFrame:CGRectInset(self.bounds, 1.0, 1.0)];
self.label.numberOfLines = 0;
self.label.layer.shouldRasterize = true;
[self addSubview:self.label];
}
return self;
}
要求に応じて
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"indexPathSection: %i in row: %i", indexPath.section, indexPath.row);
MyCVCell *cell = (MyCVCell*)[collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
NSString *str = [NSString stringWithFormat:@"%@", [[self.cData objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]];
cell.label.text = str;
return cell;
}
スクロールするまではすべて問題ないようです。原因となる可能性のあるアイデアはありますか?
スクロールする前に 下にスクロール する下に スクロールする