将UIPageViewController页面与AVCaptureSession结合使用

时间:2016-02-26 17:37:59

标签: swift uipageviewcontroller avcapturesession

我有以下设置:

具有两个子ViewControllers的UIPageviewController。 ViewController 1包含一个UITableView,ViewController 2包含一个摄像头设置(AVCaptureSession等)。它基本上是像设置一样的Snapchat。

完美地在两个作品之间滑动 - 向左滑动,UITableView正在显示,向右滑动,相机再次出现。到目前为止一切都很好。

现在我想实现一个按钮,将页面转到以编程方式保存UITableView的控制器。我是这样做的:

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

这大部分都适用,因为它滑出了拿着相机实例的UIViewController,并在持有UITableView的那个中滑动。但是,看起来保持摄像机会话的视图控制器已被解除分配,因此当我再次向右滑动时,必须再次启动摄像机。有没有办法以不同的方式翻页,而没有取消分配相机会话?

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

1 个答案:

答案 0 :(得分:0)

执行此操作的正确方法是使用具有多个子视图和启用分页的UIScrollView。当您按下按钮时,您不“翻页”,您操纵/动画滚动视图的内容。

供进一步参考: https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/UIScrollView_pg/ScrollViewPagingMode/ScrollViewPagingMode.html

相关问题