Ios 在UITabBarController中的两个子视图控制器之间转换
我有一个Ios 在UITabBarController中的两个子视图控制器之间转换,ios,uitabbarcontroller,containers,transition,childviewcontroller,Ios,Uitabbarcontroller,Containers,Transition,Childviewcontroller,我有一个UITabBarController作为我的应用程序的rootViewController,并且,除了与此类UITabBarController的选项卡项相对应的viewcontroller之外,我还有两个viewcontroller,其视图我只想成为某些选项卡项的子视图,如中所述。这些视图的框架并没有覆盖整个屏幕,当选择不同的选项卡项目时,我需要在它们之间切换 我发现可以在自定义容器视图控制器中设置子视图控制器之间转换的动画,我甚至尝试使用以下代码: // First subview'
UITabBarController
作为我的应用程序的rootViewController
,并且,除了与此类UITabBarController
的选项卡项相对应的viewcontroller之外,我还有两个viewcontroller,其视图我只想成为某些选项卡项的子视图,如中所述。这些视图的框架并没有覆盖整个屏幕,当选择不同的选项卡项目时,我需要在它们之间切换
我发现可以在自定义容器视图控制器中设置子视图控制器之间转换的动画,我甚至尝试使用以下代码:
// 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
,所以这不起作用。我找不到任何这样的例子,我怎样才能完成这个转换呢
谢谢 创建一个新类作为UITabBarController的子类,这样您就有了自定义的控制器类来适应您的需要……您的意思是,创建一个自定义类,它只是UITabBarController的一个子类?我不能让它工作…我会的。由于我正在尝试在两个视图具有相同帧的视图控制器之间切换,是否可以只使用其中一个视图控制器,而不是为两个视图控制器之间的过渡设置动画,为该视图控制器视图内容的更改设置动画?是的,但是,当你切换到另一个选项卡并再次返回时,你必须检查是否得到了预期的结果。。。