简体   繁体   中英

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. 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. Can you provide the code for loadWithArticle:?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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