gpt4 book ai didi

ios - 想要那个 .scroll 动画,即使没有在 UIPageViewController 中设置数据源

转载 作者:行者123 更新时间:2023-11-28 05:38:32 24 4
gpt4 key购买 nike

我有一个 UIPageViewController,它显示五个 ViewControllers(包含在 ViewControllers 数组中)。我正在使用手势识别器向后/向前移动页面,而不是 viewControllerBefore/viewControllerAfter 方法。它工作正常,但页面突然改变。我想让动画类似于我以前使用 .scroll 应用时的动画。我希望能够显示两个ViewControllers,类似于我们在.scroll动画中缓慢滑动时的体验。你能建议怎么做吗?谢谢。

正如我在这个问题中提到的那样,我遇到了滚动问题 -> [ Disable swiping in horizontal UICollectionView inside my PageViewController to swipe in UIPageViewController所以,我决定评论这一行 -> self.dataSource = self我决定明确提供与手势相关的功能。

@objc func handleSwipe(gesture: UISwipeGestureRecognizer) {
print(gesture.direction)
switch gesture.direction {
case UISwipeGestureRecognizer.Direction.down:
print("down swipe")
case UISwipeGestureRecognizer.Direction.up:
print("up swipe")
case UISwipeGestureRecognizer.Direction.left:

self.setViewControllers([ViewControllerArray[1]], direction: .forward, animated: false, completion: nil)

case UISwipeGestureRecognizer.Direction.right:

self.setViewControllers([ViewControllerArray[2]], direction: .forward, animated: false, completion: nil)

default:
print("other swipe")
}
}

最佳答案

animated 参数更改为 true

@objc func handleSwipe(gesture: UISwipeGestureRecognizer) {
print(gesture.direction)
switch gesture.direction {
case UISwipeGestureRecognizer.Direction.down:
print("down swipe")
case UISwipeGestureRecognizer.Direction.up:
print("up swipe")
case UISwipeGestureRecognizer.Direction.left:

self.setViewControllers([ViewControllerArray[1]], direction: .forward, animated: true, completion: nil)

case UISwipeGestureRecognizer.Direction.right:

self.setViewControllers([ViewControllerArray[2]], direction: .forward, animated: true, completion: nil)

default:
print("other swipe")
}
}

关于ios - 想要那个 .scroll 动画,即使没有在 UIPageViewController 中设置数据源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57767548/

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