0

不知道这里发生了什么。

当我在 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;

任何建议表示赞赏。

4

1 回答 1

0

我是个白痴,我没有告诉 appDelegate 中的 VC 是导航控制器。现在都在工作!即 UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController1];

于 2012-12-04T17:06:02.207 回答