2009-12-28 65 views
0

我正在嘗試開發一個工程程序。我的第一個視圖有一個文本框,用戶需要輸入「e」或「s」作爲要使用的單位(english或si),它存儲在變量es中。 AppDelegate通過applicationDidFinishLaunching:方法顯示此第一個視圖。我有一個Objective-C源文件,我正在編寫我的代碼。如何加載下一個視圖與一些文本框,用戶必須輸入一些值以保存在變量中?多視圖應用程序

回答

0

做這將是建立一個導航控制器上的應用程序代理的最簡單方法。然後,您可以輕鬆地將視圖推入或移出控制器。像這樣的東西(這裏面應用程序委託的applicationDidFinishLaunching正常工作):

// controller is defined in the header 
controller = [[UINavigationController alloc] init]; 
controller.navigationBar.barStyle = UIBarStyleBlack; 
... 
// Build your UIView 
SomeUIView *welcome = [[SomeUIView alloc] initWithNibName: @"Welcome" bundle: nil]; 
[controller pushViewController: welcome animated: NO]; 
[welcome release]; 
... 
// Display the Controller's top view in the window 
[window addSubview: controller.view]; 
[window makeKeyAndVisible]; 

然後更改視圖(該規範適用的任何地方在您的應用程序):

SomeOtherView *Detail = [[SomeOtherView alloc] initWithNibName:@"Detail" bundle:nil]; 
[self.navigationController pushViewController: Detail animated:YES]; 
[Detail release]; 

通知你總是可以得到通過「self」返回導航控制器。

好舔!