gpt4 book ai didi

ios - 为什么我不能停止 UIPageViewController 中的卷页动画

转载 作者:可可西里 更新时间:2023-11-01 01:07:17 25 4
gpt4 key购买 nike

我尝试使用 UIPageViewController 在 Controller 之间移动。一切正常,但唯一的问题是我正在将 Storyboard 中的过渡样式从 page-curl 更改为 scroll。但它不工作。当我运行应用程序并在 Controller 之间移动时,动画是 curl 的!

我的代码很简单,你可以看看:

override func viewDidLoad() {
super.viewDidLoad()
let firstViewController = orderedViewControllers[1]
setViewControllers([firstViewController],
direction: .forward,
animated: false,
completion: nil)
self.delegate = self
self.dataSource = self
}

func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
guard let viewControllerIndex = orderedViewControllers.index(of: viewController) else {
return nil
}

let previousIndex = viewControllerIndex - 1

// User is on the first view controller and swiped left to loop to
// the last view controller.
guard previousIndex >= 0 else {
return nil
}

guard orderedViewControllers.count > previousIndex else {
return nil
}
return orderedViewControllers[previousIndex]
}

func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
guard let viewControllerIndex = orderedViewControllers.index(of: viewController) else {
return nil
}

let nextIndex = viewControllerIndex + 1
let orderedViewControllersCount = orderedViewControllers.count

// User is on the last view controller and swiped right to loop to
// the first view controller.
guard orderedViewControllersCount != nextIndex else {
return nil
}

guard orderedViewControllersCount > nextIndex else {
return nil
}
return orderedViewControllers[nextIndex]
}
```

最佳答案

您需要在实例化您的 Controller 时更改此transitionStyle

PageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal)

关于ios - 为什么我不能停止 UIPageViewController 中的卷页动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55919586/

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