ios - UICollectionView 自定义 FlowLayout 指定在哪里

标签 ios iphone objective-c uicollectionview flowlayout

我想向我的 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,您应该能够将布局更改为“自定义”,然后从列表中选择您的子类。

enter image description here

关于ios - UICollectionView 自定义 FlowLayout 指定在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20164237/

相关文章:

ios - setEditing 为 ON 时如何显示 UITableViewCellAccessoryCheckmark?

ios - 如何使用 NSNotificationCenter 传输数据 ViewControllers/类?

iphone - iOS如何使iCarousel像UIScrollView页面一样滚动

带有 Google App Engine 的 iPhone 应用程序

objective-c - 在删除某个对象之前,我应该检查它是否存在于集合中吗?

ios - 是否可以检查用户何时下载我的 ios 应用程序?

iphone - 需要一个可以像闹钟应用一样使用的 iOS 4 音频 API

iphone - 应用程序在 [scrollView removeFromSuperview] 上崩溃;

objective-c - 编写 NSPredicate 格式字符串来测试多个属性的更短方法?

ios - 基于 3 个 NSPredicates 动态过滤数组