ios - 在 collectionViewCell 中使用 UIPageViewController

标签 ios swift uicollectionview uipageviewcontroller

collectionViewCell 中,我想创建一个底部带有点的 View ,我可以在 View 之间滑动。我应该使用 UIPageController 来显示点并手动实现手势识别,还是可以在 collectionViewCell 中使用 UIPageViewController

最佳答案

是的,你可以把它放在你的牢房里。它不一定是全屏。事实上,它可以用作任何其他 UIViewController。如果你想把它嵌入到一个更小的矩形中,你可以使用 UIViewController containment。

假设您想将它嵌入到父 Controller 中,该 Controller 是 UIViewController 的子类。然后定义一个pageViewController属性,在viewDidLoad中添加为 subview Controller :

self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.pageViewController.view.frame = ... //set the frame or add autolayout constraints

[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];

关于ios - 在 collectionViewCell 中使用 UIPageViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45609184/

相关文章:

android - 如何在网页上保持屏幕打开

c++ - 如何使用 Box2d 获取一个或多个碰撞点?

ios - Lua中整数后添加小数

swift - 带有解码器的 swift 中的 RLMArray : Ambiguous reference to member error

ios - 如何避免在 swift 上打开 View Controller ?

ios7 - UICollectionView 图像未显示

ios - 获取 AppStore URL 编程

swift - 将 @objc 函数作为 init 中的参数传递,以用作 UIControl 目标的操作

ios - 离开加载 Collection View 时应用程序崩溃

ios - 如何在触摸单元格内的 slider 时取消 collectionView 手势?