ios - Collection View 显示堆叠在单个 View 中的图像

标签 ios iphone uiimage

我的一个 Storyboard 有一个 TableView 单元格,它调用在单独场景中定义的 Collection View 。 Collection View 包括一个带有页面控件的 UIImage View ,直到 ios 10 升级后,每个图像都用于在 imageview 中完全显示在我重新访问 Storyboard之前,一切都变得正常。新升级中的 UIImage 或 collectionview 有什么变化吗?

相同的代码在 ipod 中运行良好。

UIImageview showing multiple images

代码示例:

#pragma mark - UICollectionViewDelegateFlowLayout

- (CGSize)collectionView:(UICollectionView *)collectionView
                  layout:(UICollectionViewLayout *)collectionViewLayout
  sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return collectionView.bounds.size;
}

是否与使用的pagecontrol有关??

最佳答案

我希望您之前使用过 sizeForItemAtIndexPath 来指定 Collection View 单元格大小,并且会添加 UICollectionViewDataSource、UICollectionViewDelegate 委托(delegate)方法。

现在对于 iOS 10,我们需要添加 UICollectionViewDelegateFlowLayout 委托(delegate),然后才会执行 sizeForItemAtIndexPath

尝试一下,希望它能解决您的问题。

关于ios - Collection View 显示堆叠在单个 View 中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40625583/

相关文章:

ios - 从哪里开始? -iOS“excel-like” View

iphone - 更改 UIView 中的坐标原点

swift - 在 UIImage 中改变 JUST .scale?

ios - UIImage 是否具有 myLabel.hidden = YES 的等价物?

ios - SVN结帐Mac终端/Xcode

ios - 从CMSampleBufferRef创建UIImage时,iOS内存增加

ios - 在 UITableView 中滚动时图像变得困惑

ios - 将 UILabel 添加为 UITextField 左侧的常量字段

ios - 当单元格在 View 外部时,ClipsToBounds重置

iphone - 如何在 iOS 中使用 PDFView 和 PDFThumbnailView?