स्क्रॉल नहीं करता है मेरे पास UICollectionView
UICollectionViewDataSource
है जो वर्तमान में छह आइटम प्रदान करता है। स्क्रीन भरने के लिए ये आवश्यक से कम हैं। समस्या यह है कि मेरा संग्रह दृश्य केवल स्क्रॉल करता है जब स्क्रीन भरने के लिए पर्याप्त आइटम होते हैं (10, 20 के साथ परीक्षण किया जाता है)। कम आइटम प्रदर्शित करते समय यह बाउंस एनीमेशन भी नहीं करेगा मैं इसे प्राप्त करने की कोशिश कर रहा हूं, यह ठीक है।UICollectionView
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateCollectionViewData) name:UIDocumentStateChangedNotification object:nil];
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
flowLayout.itemSize = CGSizeMake(160, 100);
flowLayout.minimumInteritemSpacing = 0;
flowLayout.minimumLineSpacing = 0;
self.collectionView = [[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:flowLayout];
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
self.collectionView.bounces = YES;
[self.view addSubview:self.collectionView];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [self.collectionViewData count];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath];
Expense *expense = [self.collectionViewData objectAtIndex:indexPath.row];
UILabel *label = [[UILabel alloc]initWithFrame:cell.bounds];
label.text = expense.value;
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont fontWithName:@"Miso-Bold" size:30];
label.textAlignment = NSTextAlignmentCenter;
[cell addSubview:label];
cell.backgroundColor = [UIColor colorWithRed:1 - (indexPath.row/30.0f) green:0 blue:1 alpha:1];
return cell;
}
आपकी मदद के लिए धन्यवाद!
यह सही जवाब है - ओपी को इसे उत्तर के रूप में स्वीकार करना चाहिए। –
महान टिप धन्यवाद – Fattie
धन्यवाद, यह एक आकर्षण की तरह काम करता है :) – evya