我正在为我的 UIcollectionView 使用此代码,它在 iOS6 中工作正常,但在 ios7 中无法正常工作,因为一旦我开始滚动 CollectionView,整个元素的方向就搞砸了。 对此有任何想法
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.filteredNewsItems.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
NewsItemCell *cell = (NewsItemCell *)[collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
cell.autoresizingMask = UIViewAutoresizingNone;
[cell loadWithArticle:self.filteredNewsItems[indexPath.item]];
return cell;
}
最佳答案
尝试使用
static NSString *cellIdenfier = @"collectionCell"; // this can be any string
NewsItemCell *cell = (NewsItemCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdenfier forIndexPath:indexPath];
您的单元格搞砸了,因为在重新使用滚动单元格时,在您的情况下,提供静态单元格标识符可以解决您的问题。 如果问题仍然存在,请告诉我
关于ios - UICollectionView ios 7 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19011126/