ios - UIPageViewController 中的 UISegmentControl

标签 ios objective-c uipageviewcontroller uisegmentedcontrol

我有一个 UIPageViewController,我有 4 个页面。我的其中一个页面有 UISegmentControl,用户可以在其中点击或滑动页面来更改段。我认为它在 UIPageController 内部,因此滑动会进入不同的页面,而不是在 UISegmentControl 中滑动操作,否则我可能会犯一些愚蠢的错误。这就是我所做的。我添加了两个手势识别器向左滑动和向右滑动。并在 Storyboard 中完成

SwipeGesture

最佳答案

两种解决方案:

1.在 UIPageViewController 中处理所有滑动手势。如果你不想改变你的细节 View Controller ,你可以添加一个公共(public)函数来改变一些值。在 UIPageViewControllerDataSource 你可以返回任何 View 您要展示的 Controller 。

2.使用UIGestureRecognizerDelegate。如果你不想得到这个手势,只需返回NO/false。(在UIPageViewController中为手势设置委托(delegate))

// get gesture recognizer and set delegate    
self.pageViewController!.gestureRecognizers
// decide if page controller should receive gesture
public func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool

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

相关文章:

ios - 只有大写的 UITextField Swift

ios - Instagram 故事是在 UICollectionView 还是 UIPageViewController 中?

ios - 如何使用UIPageViewController同时显示部分上一个和下一个 View

ios - 使用 PageViewController 来处理大量页面,例如相机胶卷 ImageView ?

ios - 在大纹理上渲染小纹理时,Metal 比 OpenGL 慢得多

ios - 使用主要 ID 更新 Realm 关系

iphone - 如何让两个ViewController使用一个NSObject

ios - 如何对日期对象的 NSMutableArray 进行排序

objective-c - 如何从 iPhone 上的 NSMutableArray 检索整数值?

ios - 在应用程序关闭之前,Core Data 不会保存数据