0

不知道這裏發生了什麼。使用UITabBar和NavigationController進行CAT轉換

當我這樣做的動作顯示其它的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; 

任何建議讚賞。

+0

我是一個白癡,我沒有告訴在AppDelegate VC是一個導航控制器。所有工作現在!即UINavigationController * navController2 = [[UINavigationController alloc] initWithRootViewController:viewController1]; –

回答

0

我是一個白癡我沒有告訴在AppDelegate VC是一個導航控制器。所有工作現在!即UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:viewController1];