gpt4 book ai didi

ios - UIPageViewController 中的 UISegmentControl

转载 作者:行者123 更新时间:2023-11-29 12:06:20 24 4
gpt4 key购买 nike

我有一个 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com