2013-09-25 57 views
1

我使用此代码为我的UIcollectionView,其工作正常在iOS6但与ios7和它不工作,因为一旦我开始滚动CollectionView整个元素方向搞砸了。 任何想法,这UICollection查看ios 7问题

- (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; 
} 

enter image description here

+0

你能提供截图吗? –

+0

你有快照添加。 – Alex

+0

也只有在滚动后才会发生,否则它看起来很好并且定向。 – Alex

回答

1

尝试使用

static NSString *cellIdenfier = @"collectionCell"; // this can be any string 
NewsItemCell *cell = (NewsItemCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdenfier forIndexPath:indexPath]; 

你的弄乱,因为当滚动细胞被重新使用,以便在你的情况下,提供静态小区标识,可以解决你的问题。 如果问题仍然存在,然后让我知道

+0

嗯,我正在做同样的静态NSString * reuseIdentifier = @“NewsItemCell”; ,所以它不与ios7 – Alex

+0

一起工作,所以你在哪里定义你的标识符字符串?并放置一个中断点并打印,您是否在文件顶部获得了其全局定义的正确值 –

+0

。 – Alex

0

我怀疑你的loadWithArticle:方法总是添加视图到NewsItemCell,而不是重新使用您第一次填充单元格时创建的任何现有子视图。你能否提供loadWithArticle的代码:?