gpt4 book ai didi

swift - 结合AVCaptureSession翻UIPageViewController页面

转载 作者:行者123 更新时间:2023-11-30 13:40:15 25 4
gpt4 key购买 nike

我有以下设置:

一个 UIPageviewController 有两个子 ViewController。ViewController 1 包含 UITableView,ViewController 2 包含相机设置(AVCaptureSession 等)。它基本上是一个类似 Snapchat 的设置。

在两者之间滑动效果非常好 - 向左滑动,UITableView 显示,向右滑动,相机再次显示。到目前为止一切顺利。

现在我想实现一个按钮,该按钮可以翻页以到达以编程方式保存 UITableView 的 Controller 。我是这样做的:

let startingViewController = self.viewControllerAtIndex(0)
let viewControllers: [UIViewController] = [startingViewController!]
pageViewController!.setViewControllers(viewControllers, direction: .Reverse, animated: true, completion: nil)

这在大多数情况下都有效,因为它会滑出持有相机实例的 UIViewController 并滑入持有 UITableView 的 UIViewController。然而,保存相机 session 的 View Controller 似乎已被释放,因此当我再次向右滑动时,相机必须再次启动。有没有办法以不同的方式翻页,而不释放相机 session ?

我尝试将相机添加到 PageViewcontroller 并添加“不可见”叠加层,但这不是我正在寻找的解决方案。有人可以帮忙吗?

最佳答案

正确的方法是使用具有多个 subview 并启用分页的 UIScrollView。当您按下按钮时,您不会“翻页”,而是操纵/动画 ScrollView 的内容。

更多引用: https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/UIScrollView_pg/ScrollViewPagingMode/ScrollViewPagingMode.html

关于swift - 结合AVCaptureSession翻UIPageViewController页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35658234/

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