首页 文章

强制更新屏幕外UICollectionView

提问于
浏览
2

我有两个视图控制器A和B.ViewControllerA上有一个UICollectionView .

如果我将ViewControllerB推送到ViewControllerA,那么在后台ViewControllerA 's UICollectionView updates I want to force the collection view to redraw and dequeue it' s单元格中,这样当我从ViewControllerB ViewControllerA 's data is up to date and correct. Calling reloadData doesnt make the collection view redraw it' s返回后,如果它在后台,它会等到viewWillAppear之后触发 [UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes] ,这是调用的方法数据源以使新单元出列 .

无论如何强制或欺骗集合视图,以便在调用viewWillAppear之前在新单元格上调用 [UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes]

我试图让自定义视图控制器转换工作,如果在查看ViewControllerB时ViewControllerA中的数据已更改,则看起来很奇怪 . 我想强制collectionView更新,所以当我调用CollectionView.visibileIndexPaths时,会返回正确的项目并且我的动画看起来是正确的 .

1 回答

  • 5

    在动画调用之前调用ViewControllerA视图上的layoutIfNeeded会强制在ViewControllerA返回屏幕之前更新collectionView .

相关问题