【发布时间】:2013-06-30 13:08:12
【问题描述】:
我有一个UITabBarController 作为我的应用程序的rootViewController,除了与UITabBarController 的选项卡项对应的视图控制器之外,我还有两个视图控制器,它们的视图我只想成为一个子视图对于某些选项卡项目,正如我在 this post 中解释的那样。那些view的frame并没有覆盖整个屏幕,我需要在选择不同的tab item时在它们之间切换。
我在Apple's documentation 中发现可以在自定义容器视图控制器中为子视图控制器之间的过渡设置动画,我什至尝试过使用以下代码:
// First subview's view controller is already a child
secondViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
secondViewController.view.frame = CGRectMake(0, y, secondViewController.view.frame.size.width, secondViewController.view.frame.size.height);
[self.window.rootViewController addChildViewController:secondViewController];
[firstViewController willMoveToParentViewController:nil];
[self.window.rootViewController transitionFromViewController:firstViewController
toViewController:secondViewController
duration:0.4
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:nil
completion:^(BOOL done){
[secondViewController didMoveToParentViewController:self.window.rootViewController];
[firstViewController removeFromParentViewController];
}];
但是,由于我的容器视图控制器不是自定义的,而是UITabBarController,所以这不起作用。我没有找到任何例子,我怎么能做这个过渡?
谢谢!
【问题讨论】:
标签: ios uitabbarcontroller containers transition childviewcontroller