ios - UICollectionView ios 7 问题

标签 ios objective-c ios7 uicollectionview

我正在为我的 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;
}

enter image description here

最佳答案

尝试使用

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

您的单元格搞砸了,因为在重新使用滚动单元格时,在您的情况下,提供静态单元格标识符可以解决您的问题。 如果问题仍然存在,请告诉我

关于ios - UICollectionView ios 7 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19011126/

相关文章:

ios - 在 iOS SDK 中逐行读取文件

ios - 获取 Assets 目录文件夹中所有图像的数组

iphone - 我能否使使用 iOS7 SDK 构建的应用程序在 iOS 7 中看起来像 iOS 6 应用程序?

ios - 如何将 UIButton 设置为选中和禁用

ios - 旋转图像后更改设备方向时,UIImageView 变得非常拉伸(stretch)

ios - 在表格单元格中添加到 UIView 的图形在滚动表格时表现得很奇怪

ios - 无法让 UILabels 出现在动态创建的 UIViews 上

objective-c - 容器 View Controller 状态栏 iOS 7

ios7 - 无法在 iOS 7 上登录 Sandbox 游戏中心

ios - 为 UIScrollView 子类设置缩放