通常情況下,我創造我的項目是這樣一個結構,我認爲你需要採取OverlayViewController
一個特殊的外觀,檢查出一個例子:
MainViewController - As rootViewController
|- content (Any view controller to be presented, yes inside MainViewController)
|- OverlayViewController (a view controller over content)
這種結構允許您更改內容,無需改變整個層次結構。
在MainViewController
你需要一個方法來改變當前的內容到另一個,有你如何可以做一個簡單的例子:
// PS I'm not sure if this will work in the first try, I wrote from my mind right now :)
func changeViewController (controller: UIViewController) {
let from: UIViewController
if childViewControllers.count > 0 {
from = childViewControllers.first as! UIViewController
}
else {
presentViewController(controller)
return
}
let transitionContext = SomeViewControllerContextTransitioning (
fromViewController: from,
toViewController: controller
)
transitionContext.onAnimationComplete = { success in
if !success {
// TODO: Error fallback
}
else {
from.view.removeFromSuperview()
from.removeFromParentViewController()
controller.didMoveToParentViewController(self)
}
}
from.willMoveToParentViewController(nil)
addChildViewController(controller)
SomeAnimator().animateTransition(transitionContext)
}
最後,在你的MainViewController
你可以觀察或控制您的視頻回放。
我希望這可以幫助你。