2016-07-25 52 views
0

我按照本指南Implementing a Container View Controller製作了一個可處理應用程序中的登錄/註銷的容器。防止在自定義容器中使用UINavigationBar動畫

兒童視圖控制器是:UINavigationController的進行登錄,並的UITabBarController的應用程序的其餘部分:

diagram

我的問題是,UINavigationBar的動畫奇怪的是,我想阻止它的動畫:

transition

動畫代碼基本上是這樣的(full project code here):

let current = childViewControllers.first 
    current?.willMoveToParentViewController(nil) 

    child.securityContainer = self 
    addChildViewController(child) 

     child.view.frame = newChildOriginFrame 

     UIView.transitionWithView(view, duration: 0.3, options: [], animations: { 

      child.view.frame = newChildTargetFrame 
      current?.view.frame = oldChildTargetFrame 

      self.view.addSubview(child.view) 

     }, completion: { _ in 

      child.didMoveToParentViewController(self) 
      current?.view.removeFromSuperview() 
      current?.removeFromParentViewController() 
      current?.securityContainer = nil 
     }) 

如何防止UINavigationBar的動畫?

回答

0

通過移動addSubview外動畫固定它阻止:

let current = childViewControllers.first 
current?.willMoveToParentViewController(nil) 

child.securityContainer = self 
addChildViewController(child) 

    child.view.frame = newChildOriginFrame 

    view.addSubview(child.view) 

    UIView.transitionWithView(view, duration: 0.3, options: [], animations: { 

     child.view.frame = newChildTargetFrame 
     current?.view.frame = oldChildTargetFrame 

    }, completion: { _ in 

     child.didMoveToParentViewController(self) 
     current?.view.removeFromSuperview() 
     current?.removeFromParentViewController() 
     current?.securityContainer = nil 
    }) 

full project source code

相關問題