- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有一个带有 UICollectionViewFlowLayout 的 UICollectionView。我还实现了 UICollectionViewDelegateFlowLayout 协议(protocol)。
在我的数据源中,我有一堆响应自定义协议(protocol)的 UIViewController,因此我可以询问它们的大小和其他一些东西。
在 FlowLayout 委托(delegate)中,当它要求 sizeForItemAtIndexPath: 时,我返回从我的协议(protocol)中获得的项目大小。实现我的协议(protocol)的 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.
它仍然有效,但我不喜欢它收到警告,所以也许你可以告诉我我做错了什么。还有另一个问题。如果我不告诉我的 collectionViews collectionViewLayout 在 willAnimateRotationToInterfaceOrientation 中失效:永远不会调用 sizeForItemAtIndexPath:。
希望你明白我的意思。如果您需要更多信息,请告诉我:)
最佳答案
这个答案来晚了,但接受的答案对我不起作用。我同情 OP 想要一个即发即弃的 UICollectionViewFlowLayout。我建议使 View Controller 中的布局无效实际上是最好的解决方案。
我想要一条水平滚动的单元格行,在 View 中居中,无论是纵向还是横向。
我继承了 UICollectionViewFlowLayout。
我覆盖了 prepareLayout 以重新计算插图,然后调用 [super prepareLayout]。
我覆盖了 collectionViewContentSize 的 getter 以确定内容大小是正确的。
即使边界随着重新定向而改变,布局也不会自行失效。
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
// does the superclass do anything at this point?
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
// do whatever else you need before rotating toInterfaceOrientation
// tell the layout to recalculate
[self.collectionViewLayout invalidateLayout];
}
UICollectionViewFlowLayout 维护方向之间的滚动位置。同一个单元格只有是方形的才会居中。
关于ios - UICollectionViewFlowLayout 不会使方向更改的权利失效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16341778/
我正在尝试创建一个具有如下用户配置文件的应用程序(第一张图片):https://dribbble.com/shots/1642506-Messaging-app-Viber/attachments/2
我有一个带有流布局的垂直滚动 Collection View 。我已经对布局对象进行了子类化,以便将元素在每一行的左侧对齐(使用从这里和那里借来的代码),并将节标题放在每个节的左边距(插图)上(而不是
给定一个具有流式布局的 UICollectionView,计算 Collection View 的列数(垂直方向)或行数(水平方向)的最简单方法是什么? 最佳答案 我的做法(假设所有元素具有相同的大小
我正在尝试完成以下任务,我已经使用 UIScrollview 轻松完成了此任务,但我最近一直在尝试 UICollectionView (我知道我玩游戏已经很晚了)并且很想知道是否可以这样做我想要什么,
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关于您编写的代码问题的问题必须在问题本身中描述具体问题 — 并且包括有效代码 以重现它。参见 SS
我正在使用 UICollectionViewFlowLayout 来显示 GridView ,这就是我所看到的。 问题出在左侧的缝隙上。我对使用 UICollectionViewFlowLayout
我想在 Collection View 中为每个单元格设置一个自定义大小的布局。正因为如此,我希望单元格能够很好地组合在一起,正如您在此处看到的那样: (第一个单元格是顶部单元格,然后左下角是数字 2
我对流布局进行了子类化,并将其设置为我的 Collection View 中的 collectionViewLayout。 然后我设置布局如下: - (id) init { if(self =
我有一个 UICollectionView,其中的项目可以在运行时修改它的高度。问题是当一个项目高于另一个项目时,项目周围有很多空白。 我正在寻找创建此属性的属性: 我想使用 UICollection
我正在使用 UICollectionViewFlowLayout 在水平 ScrollView 中排列 View 图 block 。默认情况下,我使用 UICollectionViewDelegate
我有一个 Collection View ,它被设置为一个水平的单元格行。它抛出以下约束错误(我正在使用 AutoLayout): The behavior of the UICollectionVi
我有一个 UICollectionView,它使用 UICollectionViewFlowLayout 的自定义子类,使节标题在滚动时粘在屏幕顶部,就像 UITableView 的普通样式一样。我的
我正在尝试修改 UICollectionViewFlowLayout(垂直滚动),以便将每个部分标题放置在该部分所有项目的左侧(而不是顶部,这是默认设置)。 也就是说,这是默认行为: ...这就是我想
我有一个带有 UICollectionViewFlowLayout 的 UICollectionView。我还实现了 UICollectionViewDelegateFlowLayout 协议(pro
我正在使用自定义 UICollectionViewFlowLayout使单元格在到达顶部时缩放和淡入淡出。为此,我正在申请 alpha和 transform到布局属性。这是我的代码( link to
我创建了一个继承自 UICollectionViewFlowLayout 的 Swift 类,并且我已经能够成功地完成一些巧妙的操作,例如更改它绘制的每个框之间的间距。我正在绘制日历,因此想象一下 2
我有一个相当标准的网格布局,使用 UICollectionViewFlowLayout 的子类.当用户点击一个单元格时,我会向下移动后续行中的单元格,以便为将出现的详细 View 腾出空间。它看起来像
经过一番摆弄后,我开始怀疑 UICollectionViewFlowLayout 的间距代码中存在错误。 问题很简单:我想在屏幕上显示五个按钮,我希望按钮之间的间距为 1 pt(视网膜显示屏上为 2
我有一个带有子类 UICollectionViewFlow 布局的 Collection View 。 我想要的效果是旋转(透视,圆形 y 轴)和运动缩放。 我的 Collection View 设置
我最近开始使用 UICollectionView,对 UICollectionViewFlowLayout 有点困惑。似乎 Collection View 中每个单元格的框架是在每个项目之间的相等空间
我是一名优秀的程序员,十分优秀!