[英]UICollection View ios 7 issues
我正在为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];
您的单元格混乱,因为在重新使用滚动单元格时,例如,提供静态单元格标识符可以解决您的问题。 如果问题仍然存在,请告诉我
我怀疑您的loadWithArticle:方法总是将视图添加到NewsItemCell,而不是重用您第一次填充单元格时创建的任何现有子视图。 您可以提供loadWithArticle:的代码吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.