2016-07-25 34 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

相关问题