使用UITabBar和NavigationController进行CAT转换

时间:2012-12-04 16:47:03

标签: ios uinavigationcontroller uitabbarcontroller core-graphics quartz-core

不确定这里发生了什么。

当我在Action中执行此操作以显示另一个viewController时:

CATransition* transition = [CATransition animation];
transition.timingFunction = [CAMediaTimingFunction  functionWithName:kCAMediaTimingFunctionEaseIn];
transition.duration = 1.0f;
transition.type =  @"cube";
transition.subtype = @"fromRight";
[self.navigationController.view.layer removeAllAnimations];
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];

forgotLoginViewController = [[ForgotLoginViewController alloc]initWithNibName:@"ForgotLoginViewController" bundle:Nil];
[self.navigationController pushViewController:forgotLoginViewController animated:YES];

它不起作用。但是当我这样做时...(在视图中添加子视图)

CATransition* transition = [CATransition animation];
transition.timingFunction = [CAMediaTimingFunction  functionWithName:kCAMediaTimingFunctionEaseIn];
transition.duration = 1.0f;
transition.type =  @"cube";
transition.subtype = @"fromRight";
[self.view.layer removeAllAnimations];
[self.view.layer addAnimation:transition forKey:kCATransition];

forgotLoginViewController = [[ForgotLoginViewController alloc]initWithNibName:@"ForgotLoginViewController" bundle:Nil];
[self.view addSubview:forgotLoginViewController.view];
它确实如此?我的Viewcontrollers和tabbar在appdelegate中实现,如下所示

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

UINavigationController *navController = [[UINavigationController alloc]
                                         initWithRootViewController:viewController2];


self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[viewController1, navController];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];

return YES;

任何建议表示赞赏。

1 个答案:

答案 0 :(得分:0)

我是个白痴我没有告诉appDelegate中的VC是导航控制器。一切正常!即UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:viewController1];