2012-09-13 46 views
1

我需要幫助,因爲我被困在我的Iphone應用程序項目中 - 我試圖瞭解我必須添加到我的代碼(以及其中)以創建第二個視圖(顯示應用程序選項或繪製圖表)並顯示它。我所見過的所有教程都提到了界面設計師,而我想以編程的方式來做到這一點(我使用cocos2D庫)。這可能聽起來像一個「似曾相識」的問題,但我找不到一個明確的解釋,我很確定這會幫助很多人。 任何提示將受到歡迎! 非常感謝你們 M.Iphone應用程序 - Cocos2D - 創建/顯示第二視圖

回答

0
AppController *app = (AppController*)[[UIApplication sharedApplication] delegate];  
[app.navController.view addSubview:newView]; 
0

,如果你想一個子視圖添加到當前現有的根控制器或重新建立一個新的視圖控制器這一切都依賴。

您可能需要添加你想要添加到您正在試圖做到這一點的實現文件的視圖的頭

這裏是代碼做重新建立新的視圖控制器的方式。

#import "FirstViewController.h" 
... 

UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

UIViewController *mvc = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil]; //Allocate the View Controller 

window.rootViewController = mvc; //Set the view controller 
[window makeKeyAndVisible]; 

的其他方式:

#import "FirstViewController.h" 
... 

UIViewController *new = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle: [NSBundle mainBundle]]; 
[self.view addSubview: new.view]; 
0

如果你的目標是創建的cocos2d的第二個觀點,那麼答案很簡單:你不能。

這是一個允許多個cocos2d視圖但迄今尚未實現的計劃功能。

相關問題