gpt4 book ai didi

iOS : Swift : Right and Left view controller transitions between mutiple view controllers

转载 作者:行者123 更新时间:2023-11-30 12:03:38 25 4
gpt4 key购买 nike

我有接近 8 个 View Controller ,每个 View Controller 都有下一个和后退按钮。我如何通过快速代码在这里进行左右转换。更具体地说,点击 back 时,上一个 View Controller 应从左侧滑动,而点击 next 时,下一个 View Controller 应从右侧滑动。

我对 iOS 开发还很陌生,任何帮助都会非常感激。

提前致谢

最佳答案

您应该能够使用UIPageViewController来做到这一点将其与其委托(delegate)结合起来。

但是,我会无耻地向您指出我的带有交互式过渡的自定义容器的开源项目 - InteractiveTransitioningContainer 。虽然它的目标是允许实现交互式容器(例如,它包含一个允许以 UIPageViewController 工作方式滑动 View Controller 的容器),但您可以使用 SwipeToSlideInteractiveTransitioningContainer 类实现你想要的:

// here you will want your 8 controllers
let vcs = [FirstViewController(), SecondViewController(), ThirdViewController()]

let container = SwipeToSlideInteractiveTransitioningContainer(with: vcs)
// this will disable swiping to navigate between containees
container.interactive = false
self.present(container, animated: true, completion: nil)

// shows the second viewController (index based from 0)
container.show(at: 1, animated: true)

// or move using previous and next convenience methods
let success = container.showNext(animated: true)

您可以使用 Cocoa pod 安装它。欢迎任何反馈:)。

关于iOS : Swift : Right and Left view controller transitions between mutiple view controllers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46913192/

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