2010-10-28 73 views
1

我一直试图弄清楚这一点现在,但我达到了一个点,我似乎无法通过阅读其他Q & As来解决我的问题。我试图让UINavigationController中的活动UIViewController发送popViewController/pushViewController消息到UINavigationController,但我无法弄清楚。我可能在做一些相当愚蠢的事情,导致它破裂。结构应该是这样的,但即使如此,我不确定我是否做得对。 secondViewController我如何pushViewController /等。从UIViewController子类?

  • mainController
    • primaryNavigationController
      • firstViewController

firstViewController和secondViewController均为A S ubclass

mainController.m

firstViewController = [[FirstTestViewController alloc] init]; 
secondViewController = [[FirstTestViewController alloc] init]; 


primaryNavigationController = [[UINavigationController alloc] 
      initWithRootViewController:firstViewController]; 
[primaryNavigationController.view setFrame:CGRectMake(0,0,320i,409)]; 
[self.view addSubview:[primaryNavigationController view]]; 
[primaryNavigationController.navigationBar setFrame:CGRectMake(0,0,20,44)]; 
primaryNavigationController.navigationBar.tintColor = [UIColor blackColor]; 

我怎么能告诉primaryNavigationController推/从firstTestViewController子类中弹出一个VC?

回答

2

您将您的第一个视图控制器内分配第二视图控制器(因为你没有之前需要它):

secondViewController = [[FirstTestViewController alloc] init]; 
[self.navigationController pushViewController:secondViewController animated:YES]; 
[secondViewController release]; 

SDK包含涉及导航控制器,并告诉你如何许多示例项目做这个。

+0

非常感谢,这正是我所期待的。我的问题是,我添加了[self.primaryNavigationController而不是[self.navigationController。 – 2010-10-29 05:22:05

相关问题