简体   繁体   English

在iOS 6和iOS 7上重新加载UICollectionView

[英]UICollectionView reload on iOS 6 and iOS 7

I am working app which uses UICollectionView. 我正在使用UICollectionView的应用程序。 This app runs very well on iOS 6 but fails to run it on iOS7. 此应用在iOS 6上运行良好,但无法在iOS7上运行。 I debug a lot and come to conclusion that reload method of UICollectionView doesn't work on iOS 7. 我进行了大量调试,得出的结论是,UICollectionView的重载方法在iOS 7上不起作用。

Is there any reason behind this? 这背后有什么原因吗?

here are the steps of my app functionality where I found issue. 这是我发现问题的应用程序功能的步骤。

  1. MyCollectionViewCell frame get changed (This is subclass of UICollectionViewCell) MyCollectionViewCell框架更改(这是UICollectionViewCell的子类)

  2. Reload collection view. 重新加载集合视图。

  3. iOS 6 works well (Here invalidate layout gets called internally then "cellAtRowOfindexpath:" ie collection view data source methods gets call)) / iOS 6运行良好(在这里无效布局在内部被调用,然后“ cellAtRowOfindexpath:”即集合视图数据源方法被调用))/

    iOS 7 doesn't work reload method (Here only invalidate layout gets called but not "cellAtRowOfindexpath:" ie collection view data source method). iOS 7无法使用重新加载方法(此处仅调用无效布局,但不调用“ cellAtRowOfindexpath:”,即集合视图数据源方法)。

Thanks in advance... 提前致谢...

the number of cells/sections in the datasource never changed, So you have to reload the visible content on the screen By calling below function of collection view 数据源中单元格/节的数量从未改变,因此您必须通过调用集合视图的以下功能来重新加载屏幕上的可见内容

[_collectionView reloadItemsAtIndexPaths:[_collectionView indexPathsForVisibleItems]];

put above line just after 放在上面之后

[_collectionView reloadData]

Hope your problem will be solved. 希望您的问题得到解决。

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

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