2016-02-26 65 views
0

我有以下设置:打开UIPageViewController页面并结合AVCaptureSession

具有两个child-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并添加一个“隐形”覆盖,但这不是我正在寻找的解决方案。有人可以帮忙吗?

回答