我想向我的 collectionView 添加一个 UIKitDynamics 效果(它不是由普通的 UIViewController 管理的)。我正在使用 Storyboard。
我正在使用本教程,但无法将代码与我的项目集成:http://www.objc.io/issue-5/collection-views-and-uidynamics.html
我已经创建了 CollectionViewFlowLayout 子类,但我不知道在哪里将它设置为自定义子类。我在 Storyboard文件中尝试过,但它不起作用。
在教程中还有这一行引用了这段代码:
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self.collectionViewLayout invalidateLayout];
}
Notice that it’s invalidating the layout when the view first appears. That’s a consequence of not using Storyboards (the timing of the first invocation of the prepareLayout method is different when using Storyboards – or not – something they didn’t tell you in the WWDC video).
这句话我不是很清楚。如果我正在使用 Storyboard,我需要做什么?
谢谢!
最佳答案
如果您在 Storyboard 中选择 UICollectionView
,您应该能够将布局更改为“自定义”,然后从列表中选择您的子类。
关于ios - UICollectionView 自定义 FlowLayout 指定在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20164237/