2012-01-22 30 views
0

我希望在我的curren RootViewController之前放置一個屏幕。到目前爲止,我已經做了如下修改MyAppDelegateiPhone:pushViewController在替換RootViewController後不工作

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    //with this in the existing RootViewController loads correctly 
    //self.window.rootViewController = self.navigationController; 
    self.window.rootViewController = [[[HomePageController alloc] init] autorelease]; 
} 

我不能完全肯定self.navigationController實際上是如何被設置爲我的RootViewController的。無論哪種方式,如果我進行修改我的HomePageController確實加載正確,但是我然後無法推動另一個視圖的頂部。我有HomePageController一個簡單的按鈕執行以下(注意HomePageController應該加載當前命名RootViewControllerHomePageController是我要坐在上面這個觀點):

RootViewController *rvC = [[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:[NSBundle mainBundle]] autorelease]; 

[self.navigationController pushViewController:rvC animated:YES]; 

運行此代碼時沒有任何反應......我不完全確定爲什麼,可能與navigationController有關?也許我沒有把HomePageController正確地或以最好的方式放在RootViewController以上?

回答

4

您目前沒有安裝navgiationController。 要解決你有

self.window.rootViewController = [[[UINavigatoinController alloc] initWithRootViewController:[[[HomePageController alloc] init] autorelease]] autorelease]; 

現在你已經安裝了navigationController及以下

[self.navigationController pushViewController:rvC animated:YES]; 

會做正確的工作,以取代

self.window.rootViewController = [[[HomePageController alloc] init] autorelease];