2009-12-28 64 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”返回导航控制器。

好舔!