IOS:将 UICollectionViews 放入 UIPageVieControllers 中

标签 ios swift view uicollectionview

在我的应用程序的一部分中,我需要一个垂直滚动装置来选择级别(我目前正在使用 Collection View )。然而,我还需要允许用户向左或向右滑动以呈现新的“楼层”级别。例如,一层和四层可能有 50 层。我喜欢 Collection View 的网格呈现,我想要 UIPageController 的页面控制功能。

我目前正在使用一个空白 View Controller (困惑地)管理它,我在其中加载了一个 Collection View 。向左滑动会重新加载此 View Controller 并告诉它加载新的 Collection View 。

我不喜欢这个,而且我不知道如何将 Collection View 网格化到 UIPageController 中。我认为这是获得我想要的东西的最佳方法,但如果有更好的方法,请告诉我。

我该怎么做?

最佳答案

没有UIPageController。我认为你的意思是 UIPageViewController

无论如何,听起来您想要类似 App Store 的“精选”选项卡的东西。在 App Store 中,有一个只能垂直滚动的顶级 Collection View 。此顶级 Collection View 的每个单元格代表一个特色类别,并包含一个(嵌套) Collection View ,该 View 仅水平滚动,并为该特色类别中的每个应用程序包含一个单元格。

所以,我的建议是:不要使用任何 UIPageViewController。执行 App Store 的操作:使用顶级垂直滚动 UICollectionView,每个单元格都包含自己的嵌套水平滚动 UICollectionView

如果您想要分页行为,请在每个嵌套 Collection View 上设置pagingEnabled(它们具有此属性,因为UICollectionViewUIScrollView的子类),或者像 App Store 一样“手动”实现它。我在 this answer 中解释了如何重现 App Store 的自定义水平停止行为.

关于IOS:将 UICollectionViews 放入 UIPageVieControllers 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43814024/

相关文章:

swift - 应用程序运行时 didReceiveRemoteNotification 未运行(前景)

linux终端查看路由器上的文件

ios - 关闭并弹出一个 View Controller

ios - 如何在 SpriteKit Swift 4 中制作垂直无限滚动背景

swift - 有什么好方法可以避免对相同的结构元素数组重复数组索引访问操作?

ios - @IBOutlet 没有出现在智能感知上

mysql - SQL : Multiple matches towards same table?

ruby-on-rails - rails 3.1 : How can I stop the view from displaying the array along with the data for 2 associated models?

ios - 如何在手机中强制执行唯一的用户名

ios - 为 tabbaritem 添加图像,但它不显示在 ios 中