简体   繁体   English

UICollection View ios 7问题

[英]UICollection View ios 7 issues

i am using this Code for my UIcollectionView , its working fine in iOS6 but with ios7 and its not working , as once i start scrolling the CollectionView the entire elements Orientation messed up. 我正在为UIcollectionView使用此代码,它在iOS6上可以正常工作,但在ios7上却不能正常工作,因为一旦我开始滚动CollectionView,整个元素的方向就混乱了。 Any idea to this 任何想法

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

在此处输入图片说明

try to use 尝试使用

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

your cell got messed up because while scrolling cell is re used so as in your case providing static cell identifier can fix your problem. 您的单元格混乱,因为在重新使用滚动单元格时,例如,提供静态单元格标识符可以解决您的问题。 if problem still persist with you then let me know 如果问题仍然存在,请告诉我

I suspect your loadWithArticle: method is always adding views to the NewsItemCell rather than reusing any existing subviews that you created the first time the cell was populated. 我怀疑您的loadWithArticle:方法总是将视图添加到NewsItemCell,而不是重用您第一次填充单元格时创建的任何现有子视图。 Can you provide the code for loadWithArticle:? 您可以提供loadWithArticle:的代码吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM