小编Ped*_*mão的帖子

UICollectionViewFlowLayout在方向更改时不会失效

我有一个带有UICollectionViewFlowLayout的UICollectionView.我还实现了UICollectionViewDelegateFlowLayout协议.

在我的数据源中,我有一堆UIViewControllers响应自定义协议,所以我可以询问它们的大小和其他一些东西.

在FlowLayout委托中,当它要求sizeForItemAtIndexPath:时,我返回从我的协议获得的项目大小.实现我的协议的ViewControllers根据方向返回不同的项目大小.

现在,如果我将设备方向从纵向更改为横向,则没有问题(项目在横向上更大)但如果我将其更改回来,我会收到此警告:

    the item width must be less that the width of the UICollectionView minus the section insets left and right values.
    Please check the values return by the delegate.
Run Code Online (Sandbox Code Playgroud)

它仍然有效,但我不喜欢它得到警告所以也许你可以告诉我我做错了什么.还有另一个问题.如果我没有告诉我的collectionViews collectionViewLayout在willAnimateRotationToInterfaceOrientation中失效:从不调用sizeForItemAtIndexPath :.

希望你明白我的意思.如果您需要其他信息,请告诉我:)

ios uicollectionview uicollectionviewlayout

22
推荐指数
3
解决办法
2万
查看次数