简体   繁体   English

iOS:Swift:多个视图控制器之间的右视图和左视图控制器转换

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

I have close to 8 view controllers , Each and every view controller has next and back button . 我有接近8个视图控制器,每个视图控制器都有“下一步”和“后退”按钮。 How could I do left and right transitions here through swift code . 我如何通过快速代码在这里进行左右转换。 To be more specific on tapping back , previous view controller should slide from left and on tapping next , the next view controller should slide from right. 为了更具体地敲击,上一个视图控制器应从左滑动,而在下一个敲击时,下一个视图控制器应从右滑动。

I am pretty new to iOS development , Any help would be really appreciable. 我对iOS开发非常陌生,任何帮助都将不胜感激。

Thanks In Advance 提前致谢

You should be able to do it using UIPageViewController combining it with its delegate. 您应该能够通过结合使用UIPageViewController和它的委托来做到这一点。

However, I'm gonna shamelessly point you to my open source project of custom container with interactive transitions - InteractiveTransitioningContainer . 但是,我会毫不客气地将您指向具有交互式转换的自定义容器的开源项目-InteractiveTransitioningContainer While it aims at allowing to implement an interactive container (as an example it includes a container that allows swiping through viewControllers the way as UIPageViewController works), you can use the SwipeToSlideInteractiveTransitioningContainer class to achieve what you want: 虽然它旨在实现一个交互式容器(例如,它包含一个允许以UIPageViewController的方式在UIPageViewController滑动的容器),但是您可以使用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)

You can install it using Cocoa pods. 您可以使用可可豆荚进行安装。 Any feedback welcome :). 欢迎任何反馈:)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM