[英]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.