2016-02-26 62 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並添加一個「隱形」覆蓋,但這不是我正在尋找的解決方案。有人可以幫忙嗎?

回答